Token导航 LogoToken导航

MCP Server · 开发工具

Ts MCP Server

一个轻量级的TypeScript/JavaScript重构和代码智能服务器,提供40种工具直接映射到tsserver协议命令,用于符号重命名、函数提取、文件移动等结构化代码更改。

stdio官方级别未说明来源级核验工具 39ts-mcp-server
TypeScriptClaude开发工具CursorWindsurfVS Code

快速开始

作者 / 组织
AndyLiner13
提供方
AndyLiner13
运行时
Node.js

工具数量

39

来源目录标注

资源数量

0

来源目录标注

提示词数量

0

来源目录标注

GitHub Star

1

仓库热度

收录来源

1 个

MCP World

选型结论

Ts MCP Server 属于开发工具类 MCP Server,公开资料标注 39 个工具,通过stdio 本地进程接入,适配 Claude、Cursor、Windsurf,有可以直接复制的安装命令;接入前先确认权限范围。

分类

开发工具

传输方式

stdio

认证方式

无需认证

部署方式

公开资料未说明

安装与配置

安装命令

npx ts-mcp-server

客户端配置示例

{
  "mcpServers": {
    "ts-mcp-server": {
      "command": "npx",
      "args": [
        "ts-mcp-server"
      ]
    }
  }
}

按公开安装命令拼出来的示例,字段名和参数以仓库 README 为准;带 YOUR_API_KEY 这类占位符的位置记得换成自己的值。

上手步骤

  1. 1

    准备运行环境

    stdio 服务在本地起进程,需要先装好 Node.js,再按安装命令拉取依赖。

  2. 2

    安装服务

    复制下面的安装命令执行;命令里带占位符的位置换成自己的密钥或路径。

  3. 3

    写入客户端配置

    在客户端的 MCP 配置里填启动命令和参数,保存后完全退出客户端再打开,让新配置生效。

  4. 4

    验证是否可用

    连接成功后客户端会列出 39 个工具,随便调一个只读工具确认能返回结果。

接入前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

详细介绍

ts mcp服务器

轻量级 模型上下文协议 (MCP)服务器 TypeScript和JavaScript重构和代码智能每个工具都直接映射到 tsserver protocol命令——输出是TypeScript编译器未经修改的原始响应。重命名符号、提取函数、在文件之间移动声明、重新组织导入、导航类型层次结构、探索调用图、在工作区中搜索符号、将AI生成的代码映射到正确的位置、发现哪些错误代码具有自动修复功能等等——每一个 import, require,重新导出,并在整个代码库中自动更新引用。

为什么

AI编码助手可以读写代码,但他们很难做到 结构性变化 这会波及许多文件。重命名函数、提取助手、移动React组件或重新组织文件夹意味着更新每个涉及它的引用和导入。错过一个,构建就会中断。

ts-mcp-server 提供任何兼容MCP的客户端-- VS代码副本, 克劳德桌面, 光标, 帆板运动, 继续,以及其他——执行这些重构的能力 正确和完全,使用TypeScript自己的编译器基础架构。

特性

  • 40工具 --每个都以1:1的比例映射到本地 tsserver 协议命令

重构(14个工具)

  • 重命名符号 --变量、函数、类、类型、属性、接口、枚举——每个文件中的所有引用都会更新
  • 重命名/移动文件和文件夹 --所有导入路径自动更新
  • 提取功能 --将代码范围提取到具有自动检测参数和返回类型的新函数中
  • 提取常量 --将表达式提取到具有推断类型的命名常量中
  • 提取类型 --将内联类型注释提取到命名类型别名中
  • 推断返回类型 --向函数添加显式返回类型注释,由TypeScript推断
  • 移动符号 --将顶级声明移动到另一个文件,所有导入都会自动重新连接
  • 内联变量 --将所有引用替换为变量的初始值设定项并删除声明
  • 组织导入 --排序、合并和删除未使用的导入
  • 格式 --根据TypeScript的格式化规则格式化一系列代码
  • 获取代码修复 --检索特定诊断的可用自动修复程序(缺少导入、类型不匹配等)
  • 获取组合代码修复 --对文件中的特定错误代码应用全部修复操作
  • 获取诊断信息 --检索任何文件的类型错误、警告和建议
  • 查找所有引用 --在整个项目中查找符号的每次使用
  • 地图代码 --将AI生成的代码片段映射到文件中,用名称替换匹配的声明或附加新的声明
  • 获取支持的代码修复 --列出具有可用自动修复的每个错误代码,可选地将其范围限定在项目中

代码智能(24种工具)

  • 快捷信息 --任何符号的完整类型信息、文档和JSDoc标签(悬停信息)
  • 导航树 --文件的完整层次结构(所有声明及其嵌套)
  • 转到定义 --跳转到声明符号的位置
  • 定义和界限跨度 --类似定义,但也返回查询符号的文本跨度
  • 查找源定义 --导航到实际的TypeScript源代码,而不是 .d.ts 申报文件
  • 转到类型定义 --跳转到类型的定义,而不是变量的声明
  • 转到实施 --查找接口或抽象类的具体实现
  • 导航到符号 --按名称搜索工作区范围内的符号
  • 文件引用 --查找导入给定文件的每个文件(反向依赖关系图)
  • 准备呼叫层次结构 --获取函数/方法的调用层次结构入口点
  • 来电 --查找函数的所有调用者(“谁调用这个?”)
  • 呼出电话 --查找函数的所有被调用者(“这调用什么?”)
  • 项目信息 --获取tsconfig.json路径、文件列表和语言服务状态
  • 完工信息 --在某个位置自动完成建议
  • 完成条目详细信息 --完成项目的完整文件和类型签名
  • 签名帮助 --调用站点的函数参数信息和重载
  • 文档亮点 --文件中出现的所有符号,具有读/写区别
  • 获取适用的重构工具 --发现某个位置或选择中可用的重构
  • 选择范围 --为智能扩展/收缩选择获取语义上有意义的选择范围
  • 转到重构建议 --移动符号时获取建议的目标文件
  • 文档注释模板 --为函数/方法生成JSDoc注释模板
  • 轮廓跨度 --获取文件中的可折叠区域
  • 镶嵌提示 --获取一个范围的镶嵌提示(参数名称、推断类型)
  • TODO评论 --在文件中查找所有TODO/FIXME/HACK注释

设计原则

  • 纯tsserver输出 --每个工具都会返回未经修改的原始数据 tsserver 响应为JSON
  • 预览模式 --在应用任何东西之前,先看看会发生什么变化
  • 自动项目发现 — tsconfig.json 自动检测;无需配置
  • 多项目支持 --monorepos、项目引用和复合构建开箱即用
  • 跨平台 --Windows、macOS和Linux

运作原理

在引擎盖下, ts-mcp-server 与TypeScript通信 tsserver 通过节点IPC——与VS Code使用的协议相同。每个工具都是一个薄薄的包装:

  1. 将您的输入直接传递给 tsserver 协议命令
  2. 返回原始响应--无格式、无分组、无筛选

重构工具:

工具tsserver命令
renamerename-full → renameLocations-full
renameFileOrDirectorygetEditsForFileRename-full
referencesreferences
getDiagnosticssemanticDiagnosticsSync + suggestionDiagnosticsSync
organizeImportsorganizeImports-full
getCodeFixesgetCodeFixes
extractFunctiongetEditsForRefactor-full
extractConstantgetEditsForRefactor-full
extractTypegetEditsForRefactor-full
inferReturnTypegetEditsForRefactor-full
moveSymbolgetEditsForRefactor-full
inlineVariablegetEditsForRefactor-full
formatformat
mapCodemapCode
getSupportedCodeFixesgetSupportedCodeFixes

代码智能工具:

工具tsserver命令
quickinfoquickinfo
navtreenavtree
definitiondefinition
typeDefinitiontypeDefinition
implementationimplementation
navtonavto
fileReferencesfileReferences
prepareCallHierarchyprepareCallHierarchy
provideCallHierarchyIncomingCallsprovideCallHierarchyIncomingCalls
provideCallHierarchyOutgoingCallsprovideCallHierarchyOutgoingCalls
projectInfoprojectInfo
completionInfocompletionInfo
completionEntryDetailscompletionEntryDetails
signatureHelpsignatureHelp
documentHighlightsdocumentHighlights
getApplicableRefactorsgetApplicableRefactors
getCombinedCodeFixgetCombinedCodeFix
getOutliningSpansgetOutliningSpans
todoCommentstodoComments
docCommentTemplatedocCommentTemplate
provideInlayHintsprovideInlayHints
definitionAndBoundSpandefinitionAndBoundSpan
findSourceDefinitionfindSourceDefinition
selectionRangeselectionRange
getMoveToRefactoringFileSuggestionsgetMoveToRefactoringFileSuggestions

没有正则表达式,没有自定义路径解析,没有启发式,没有输出格式。TypeScript编译器完成了所有的工作。

快速开始

安装

npx ts-mcp-server

配置您的MCP客户端

添加 ts-mcp-server 根据客户的MCP配置。

VS Code (.vscode/mcp.json):

{
  "servers": {
    "ts-mcp-server": {
      "command": "npx",
      "args": ["ts-mcp-server"]
    }
  }
}

克劳德桌面 (claude_desktop_config.json):

{
  "mcpServers": {
    "ts-mcp-server": {
      "command": "npx",
      "args": ["ts-mcp-server"]
    }
  }
}

光标,风帆,继续 --使用相同的方法遵循每个客户端的MCP服务器文档 npx ts-mcp-server 命令。

禁用单个工具

通过将其名称设置为,可以单独禁用每个工具 "false" 在 env MCP配置的块。默认情况下,工具处于启用状态;仅将工具明确设置为 "false" 在启动时跳过。

VS Code (.vscode/mcp.json):

{
  "servers": {
    "ts-mcp-server": {
      "command": "npx",
      "args": ["ts-mcp-server"],
      "env": {
        "todoComments": "false",
        "getOutliningSpans": "false",
        "docCommentTemplate": "false"
      }
    }
  }
}

克劳德桌面 (claude_desktop_config.json):

{
  "mcpServers": {
    "ts-mcp-server": {
      "command": "npx",
      "args": ["ts-mcp-server"],
      "env": {
        "todoComments": "false",
        "getOutliningSpans": "false",
        "docCommentTemplate": "false"
      }
    }
  }
}

中的工具名称 env 必须与中列出的工具名称完全匹配 工具参考 下面(例如。, "quickinfo", "getDiagnostics", "extractFunction").任何其他值(包括完全省略键)都会使该工具处于启用状态。

工具参考

rename

重命名Types/JavaScript符号并更新整个项目中的所有引用。

参数类型必填说明
filestring✅包含符号的文件路径(绝对或相对于cwd)
linenumber✅符号出现的从1开始的行号
offsetnumber✅行上基于1的字符偏移
newNamestring✅符号的新名称
previewboolean✅如果 true,返回更改而不应用

示例:

rename  file="src/utils/helpers.ts"  line=5  offset=17  newName="formatCurrency"
rename  file="src/components/Button.tsx"  line=10  offset=17  newName="PrimaryButton"
rename  file="src/types.ts"  line=3  offset=11  newName="UserProfile"
rename  file="src/utils/helpers.ts"  line=5  offset=17  newName="formatCurrency"  preview=true

______________________________________________________________________

renameFileOrDirectory

重命名或移动TypeScript/JavaScript文件或目录,并更新整个项目中的所有导入路径。

参数类型必填说明
fromstring✅当前文件或目录路径(相对于cwd的绝对或相对路径)
tostring✅新文件或目录路径(相对于cwd的绝对或相对路径)
previewboolean✅如果 true,返回更改而不应用

示例:

renameFileOrDirectory  from="src/utils/helpers.ts"  to="src/utils/string-helpers.ts"
renameFileOrDirectory  from="src/Button.tsx"  to="src/components/ui/Button.tsx"
renameFileOrDirectory  from="src/components/primitives"  to="src/components/ui"
renameFileOrDirectory  from="src/old-name.ts"  to="src/new-name.ts"  preview=true

______________________________________________________________________

references

查找项目中符号的所有用法。

参数类型必填说明
filestring✅文件路径(绝对或相对于cwd)
linenumber✅符号出现的从1开始的行号
offsetnumber✅行上基于1的字符偏移

示例:

references  file="src/utils/helpers.ts"  line=5  offset=17
references  file="src/types.ts"  line=3  offset=11

______________________________________________________________________

getDiagnostics

获取文件的所有错误、警告和建议。将语义诊断和建议诊断作为单独的数组返回。

参数类型必填说明
filestring✅文件路径(绝对或相对于cwd)

示例:

getDiagnostics  file="src/utils/helpers.ts"
getDiagnostics  file="src/components/Button.tsx"
注: 未使用的代码诊断(未使用的变量、未使用的导入)仅在以下情况下显示 tsconfig.json 有 noUnusedLocals 和 noUnusedParameters 启用。

______________________________________________________________________

organizeImports

对文件中未使用的导入进行排序、合并和删除。

参数类型必填说明
filestring✅文件路径(绝对或相对于cwd)
previewboolean✅如果 true,返回更改而不应用

示例:

organizeImports  file="src/utils/helpers.ts"
organizeImports  file="src/components/Button.tsx"  preview=true

______________________________________________________________________

getCodeFixes

获取文件中某个范围内特定错误代码的可用代码修复。使用 getDiagnostics 首先发现错误代码和范围,然后将其传递到此处。

参数类型必填说明
filestring✅文件路径(绝对或相对于cwd)
startLinenumber✅基于1的诊断范围起始线
startOffsetnumber✅基于1的起始字符偏移
endLinenumber✅基于1的诊断范围终点线
endOffsetnumber✅基于1的结束字符偏移
errorCodesnumber[]✅用于修复的诊断错误代码

示例:

# Get fixes for a "Cannot find name" error (code 2304) at line 10
getCodeFixes  file="src/app.ts"  startLine=10  startOffset=1  endLine=10  endOffset=20  errorCodes=[2304]

# Get fixes for multiple error codes
getCodeFixes  file="src/app.ts"  startLine=5  startOffset=1  endLine=5  endOffset=30  errorCodes=[2304, 2552]

______________________________________________________________________

getCombinedCodeFix

获取一个组合代码修复,在一个操作中跨文件应用修复的所有实例。返回完整的文件编辑集作为 CombinedCodeActions 回应。使用 getCodeFixes 首先发现可用 fixId 值,然后传递 fixId 在这里获取整个文件的组合修复。

参数类型必填说明
filestring✅文件路径(绝对或相对于cwd)
fixIdstring✅来自代码修复的fixId(例如。, "fixMissingImport", "unusedIdentifier", "inferFromUsage")

示例:

# Get the combined "add all missing imports" fix for a file
getCombinedCodeFix  file="src/app.ts"  fixId="fixMissingImport"

# Get the combined "remove all unused variables" fix for a file
getCombinedCodeFix  file="src/app.ts"  fixId="unusedIdentifier"

______________________________________________________________________

extractFunction

将选定的代码范围提取到新函数中。TypeScript自动检测参数和返回类型。回应包括 renameFilename / renameLocation 所以你可以跟进 rename 给函数起一个有意义的名字。

参数类型必填说明
filestring✅文件路径(绝对或相对于cwd)
startLinenumber✅从1开始选择
startOffsetnumber✅基于1的起始字符偏移
endLinenumber✅基于1的选择结束行
endOffsetnumber✅基于1的结束字符偏移
previewboolean✅如果 true,返回更改而不应用

示例:

# Extract lines 10-15 into a function
extractFunction  file="src/app.ts"  startLine=10  startOffset=1  endLine=15  endOffset=1

# Preview the extraction
extractFunction  file="src/app.ts"  startLine=10  startOffset=1  endLine=15  endOffset=1  preview=true

______________________________________________________________________

extractConstant

将所选表达式提取到命名常量中。TypeScript推断类型。回应包括 renameFilename / renameLocation 所以你可以跟进 rename 给常量一个有意义的名称。

参数类型必填说明
filestring✅文件路径(绝对或相对于cwd)
startLinenumber✅表达式的从1开始的起始行
startOffsetnumber✅基于1的起始字符偏移
endLinenumber✅表达式的1基结束行
endOffsetnumber✅基于1的结束字符偏移
previewboolean✅如果 true,返回更改而不应用

示例:

# Extract an expression into a constant
extractConstant  file="src/app.ts"  startLine=8  startOffset=12  endLine=8  endOffset=35

# Preview the extraction
extractConstant  file="src/app.ts"  startLine=8  startOffset=12  endLine=8  endOffset=35  preview=true

______________________________________________________________________

moveSymbol

将顶级声明(函数、类、类型、常量)移动到另一个文件。整个项目中的所有导入都会自动重新连接。如果目标文件不存在,tsserver会创建它。

参数类型必填说明
filestring✅源文件路径(绝对或相对于cwd)
startLinenumber✅声明的起始行从1开始
startOffsetnumber✅基于1的起始字符偏移
endLinenumber✅声明的基于1的结束行
endOffsetnumber✅基于1的结束字符偏移
targetFilestring✅目标文件路径(绝对或相对于cwd)
previewboolean✅如果 true,返回更改而不应用

示例:

# Move a function to a utility file
moveSymbol  file="src/app.ts"  startLine=20  startOffset=1  endLine=35  endOffset=2  targetFile="src/utils/helpers.ts"

# Move a type to a shared types file
moveSymbol  file="src/components/Button.tsx"  startLine=1  startOffset=1  endLine=5  endOffset=2  targetFile="src/types.ts"

# Preview the move
moveSymbol  file="src/app.ts"  startLine=20  startOffset=1  endLine=35  endOffset=2  targetFile="src/utils/helpers.ts"  preview=true

______________________________________________________________________

inlineVariable

内联一个变量——用变量的初始化器替换所有引用并删除声明。位置必须位于其声明或任何用法中的变量名上。

参数类型必填说明
filestring✅文件路径(绝对或相对于cwd)
linenumber✅变量的从1开始的行号
offsetnumber✅行上基于1的字符偏移
previewboolean✅如果 true,返回更改而不应用

示例:

# Inline a variable
inlineVariable  file="src/app.ts"  line=12  offset=7

# Preview the inlining
inlineVariable  file="src/app.ts"  line=12  offset=7  preview=true

______________________________________________________________________

extractType

将内联类型注释提取到命名类型别名中。选择要提取的类型跨度。回应包括 renameFilename / renameLocation 所以你可以跟进 rename 为该类型赋予一个有意义的名称。

参数类型必填说明
filestring✅文件路径(绝对或相对于cwd)
startLinenumber✅span类型的基于1的起始行
startOffsetnumber✅基于1的起始字符偏移
endLinenumber✅span类型的基于1的端线
endOffsetnumber✅基于1的结束字符偏移
previewboolean✅如果 true,返回更改而不应用

示例:

# Extract an inline object type into a type alias
# Given: function process(user: { id: number; name: string }) { ... }
# Select the span "{ id: number; name: string }"
extractType  file="src/app.ts"  startLine=5  startOffset=26  endLine=5  endOffset=56

# Preview the extraction
extractType  file="src/app.ts"  startLine=5  startOffset=26  endLine=5  endOffset=56  preview=true

______________________________________________________________________

inferReturnType

向函数添加一个显式的返回类型注释,由TypeScript推断。位置必须位于函数名或声明关键字上(function, async,箭头函数变量名)。

参数类型必填说明
filestring✅文件路径(绝对或相对于cwd)
linenumber✅函数的从1开始的行号
offsetnumber✅行上基于1的字符偏移
previewboolean✅如果 true,返回更改而不应用

示例:

# Add return type to a function that currently has none
# Given: function greet(name: string) { return `Hello, ${name}!`; }
# After: function greet(name: string): string { return `Hello, ${name}!`; }
inferReturnType  file="src/app.ts"  line=10  offset=10

# Preview the change
inferReturnType  file="src/app.ts"  line=10  offset=10  preview=true

quickinfo

获取给定位置符号的完整类型信息、文档和JSDoc标签。这是“悬停”信息。

参数类型必填说明
filestring✅文件路径(绝对或相对于cwd)
linenumber✅从1开始的行号
offsetnumber✅行上基于1的字符偏移

示例:

quickinfo  file="src/utils/helpers.ts"  line=5  offset=17
quickinfo  file="src/types.ts"  line=3  offset=11

______________________________________________________________________

navtree

获取文件的完整层次结构——所有类、函数、变量、接口、类型别名、枚举及其嵌套。

参数类型必填说明
filestring✅文件路径(绝对或相对于cwd)

示例:

navtree  file="src/utils/helpers.ts"
navtree  file="src/components/Button.tsx"

______________________________________________________________________

definition

转到符号的定义。返回声明符号的文件位置。

参数类型必填说明
filestring✅文件路径(绝对或相对于cwd)
linenumber✅从1开始的行号
offsetnumber✅行上基于1的字符偏移

示例:

definition  file="src/app.ts"  line=10  offset=5
definition  file="src/components/Button.tsx"  line=3  offset=15

______________________________________________________________________

typeDefinition

导航到类型的定义,而不是变量的声明。给定 const user: UserProfile = ..., definition 转到变量,但是 typeDefinition 转到 UserProfile 界面。

参数类型必填说明
filestring✅文件路径(绝对或相对于cwd)
linenumber✅从1开始的行号
offsetnumber✅行上基于1的字符偏移

示例:

typeDefinition  file="src/app.ts"  line=10  offset=12
typeDefinition  file="src/services/api.ts"  line=5  offset=8

______________________________________________________________________

implementation

查找接口或抽象类的具体实现。给定一个接口 Serializable,返回实现它的每个类。

参数类型必填说明
filestring✅文件路径(绝对或相对于cwd)
linenumber✅从1开始的行号
offsetnumber✅行上基于1的字符偏移

示例:

implementation  file="src/types.ts"  line=1  offset=18
implementation  file="src/interfaces/repository.ts"  line=3  offset=18

______________________________________________________________________

navto

按名称搜索工作区范围内的符号。获取搜索字符串,并返回所有项目文件中的匹配符号及其位置和类型。

参数类型必填说明
searchValuestring✅要搜索的符号名称或前缀
filestring--项目上下文的可选文件(绝对或相对于cwd)
maxResultCountnumber--要返回的最大结果数
currentFileOnlyboolean--如果 true,仅搜索指定的文件

示例:

navto  searchValue="User"  file="src/app.ts"
navto  searchValue="handle"  file="src/app.ts"  maxResultCount=10
navto  searchValue="Button"  file="src/components/Button.tsx"  currentFileOnly=true

______________________________________________________________________

fileReferences

查找导入或引用给定文件的每个文件。单个文件的反向依赖关系图。

参数类型必填说明
filestring✅文件路径(绝对或相对于cwd)

示例:

fileReferences  file="src/utils/helpers.ts"
fileReferences  file="src/types.ts"

______________________________________________________________________

prepareCallHierarchy

在某个位置获取调用层次结构项——调用层次结构查询的入口点。返回函数/方法名称、种类、文件位置和跨度。

参数类型必填说明
filestring✅文件路径(绝对或相对于cwd)
linenumber✅从1开始的行号
offsetnumber✅行上基于1的字符偏移

示例:

prepareCallHierarchy  file="src/services/api.ts"  line=10  offset=17
prepareCallHierarchy  file="src/utils/helpers.ts"  line=5  offset=17

______________________________________________________________________

provideCallHierarchyIncomingCalls

查找在给定位置调用函数的所有函数/方法。回答“谁叫这个?”

参数类型必填说明
filestring✅文件路径(绝对或相对于cwd)
linenumber✅从1开始的行号
offsetnumber✅行上基于1的字符偏移

示例:

provideCallHierarchyIncomingCalls  file="src/services/api.ts"  line=10  offset=17
provideCallHierarchyIncomingCalls  file="src/utils/helpers.ts"  line=5  offset=17

______________________________________________________________________

provideCallHierarchyOutgoingCalls

查找给定位置的函数调用的所有函数/方法。回答“这叫什么?”

参数类型必填说明
filestring✅文件路径(绝对或相对于cwd)
linenumber✅从1开始的行号
offsetnumber✅行上基于1的字符偏移

示例:

provideCallHierarchyOutgoingCalls  file="src/services/api.ts"  line=10  offset=17
provideCallHierarchyOutgoingCalls  file="src/utils/helpers.ts"  line=5  offset=17

______________________________________________________________________

projectInfo

获取tsconfig.json路径、项目中文件的完整列表以及语言服务是否处于活动状态。

参数类型必填说明
filestring✅文件路径(绝对或相对于cwd)
needFileNameListboolean--如果 true,包括项目中所有文件的列表(默认值: true)

示例:

projectInfo  file="src/app.ts"
projectInfo  file="src/app.ts"  needFileNameList=false

______________________________________________________________________

completionInfo

在某个位置获取自动完成建议。返回所有可能的补全及其类型、排序文本和插入文本。有助于了解某个位置可用的符号、方法或属性。

参数类型必填说明
filestring✅文件路径(绝对或相对于cwd)
linenumber✅从1开始的行号
offsetnumber✅行上基于1的字符偏移
prefixstring--筛选完成项的可选前缀
triggerCharacterstring--触发完成的字符(例如。, ., ", ', ` `, /, @, <, #, `)

示例:

completionInfo  file="src/app.ts"  line=10  offset=15
completionInfo  file="src/app.ts"  line=10  offset=15  prefix="get"
completionInfo  file="src/app.ts"  line=10  offset=15  triggerCharacter="."

______________________________________________________________________

completionEntryDetails

获取特定完成项的完整详细信息——文档、完整类型签名、JSDoc标签和代码操作(如自动导入)。用作后续 completionInfo.

参数类型必填说明
filestring✅文件路径(绝对或相对于cwd)
linenumber✅从1开始的行号
offsetnumber✅行上基于1的字符偏移
entryNamesstring[]✅获取详细信息的完成条目名称

示例:

completionEntryDetails  file="src/app.ts"  line=10  offset=15  entryNames=["map","filter"]
completionEntryDetails  file="src/app.ts"  line=5  offset=10  entryNames=["useState"]

______________________________________________________________________

signatureHelp

在调用站点获取函数/方法签名信息。返回每个重载的参数名称、类型和文档。当光标位于函数调用括号内时使用。

参数类型必填说明
filestring✅文件路径(绝对或相对于cwd)
linenumber✅从1开始的行号
offsetnumber✅基于1的字符偏移量(在函数调用括号内)
triggerReasonobject--可选: `{ kind: "invoked" \"retrigger" \"characterTyped", triggerCharacter?: string }`

示例:

signatureHelp  file="src/app.ts"  line=12  offset=20
signatureHelp  file="src/app.ts"  line=12  offset=20  triggerReason={"kind":"invoked"}

______________________________________________________________________

documentHighlights

查找文件(或文件集)中出现的所有符号。区分读和写引用。比 references 当你只需要本地事件时。

参数类型必填说明
filestring✅文件路径(绝对或相对于cwd)
linenumber✅从1开始的行号
offsetnumber✅行上基于1的字符偏移
filesToSearchstring[]--可选:将搜索限制为这些文件

示例:

documentHighlights  file="src/app.ts"  line=10  offset=5
documentHighlights  file="src/app.ts"  line=10  offset=5  filesToSearch=["src/app.ts","src/utils.ts"]

______________________________________________________________________

getApplicableRefactors

了解某个位置或选择中可用的重构。在尝试重构之前使用,看看有什么可能。返回可用重构器的列表及其操作名称和描述。

参数类型必填说明
filestring✅文件路径(绝对或相对于cwd)
startLinenumber✅从1开始选择
startOffsetnumber✅基于1的起始字符偏移
endLinenumber✅基于1的选择结束行
endOffsetnumber✅基于1的结束字符偏移
triggerReasonstring—"invoked" 或 "implicit"

示例:

getApplicableRefactors  file="src/app.ts"  startLine=10  startOffset=1  endLine=15  endOffset=1
getApplicableRefactors  file="src/app.ts"  startLine=8  startOffset=12  endLine=8  endOffset=35

______________________________________________________________________

docCommentTemplate

为某个位置的函数、方法或类生成JSDoc注释模板。返回模板文本 @param, @returns等等。

参数类型必填说明
filestring✅文件路径(绝对或相对于cwd)
linenumber✅从1开始的行号
offsetnumber✅行上基于1的字符偏移

示例:

docCommentTemplate  file="src/utils/helpers.ts"  line=10  offset=1
docCommentTemplate  file="src/services/api.ts"  line=25  offset=10

______________________________________________________________________

getOutliningSpans

获取文件的代码折叠区域。返回代码块的层次结构,包括其种类(注释、区域、代码、导入)。有助于理解文件结构和复杂性。

参数类型必填说明
filestring✅文件路径(绝对或相对于cwd)

示例:

getOutliningSpans  file="src/app.ts"
getOutliningSpans  file="src/components/Button.tsx"

______________________________________________________________________

provideInlayHints

获取范围的嵌体提示(内联类型注释)。显示推断类型、调用站点的参数名称和返回类型。有助于理解TypeScript在没有显式类型注释的情况下推断什么。

参数类型必填说明
filestring✅文件路径(绝对或相对于cwd)
startnumber✅起始偏移量(基于0的字符位置)
lengthnumber✅范围长度(字符)

示例:

# Get inlay hints for the first 1000 characters of a file
provideInlayHints  file="src/app.ts"  start=0  length=1000

# Get inlay hints for a specific range
provideInlayHints  file="src/utils/helpers.ts"  start=500  length=200

______________________________________________________________________

todoComments

在文件中查找所有TODO、FIXME、HACK和其他配置的注释标记。返回每个匹配注释的位置和文本。

参数类型必填说明
filestring✅文件路径(绝对或相对于cwd)
descriptors{text: string, priority: number}[]✅要搜索的评论标记数组(例如TODO、FIXME)

示例:

# Find all TODO and FIXME comments
todoComments  file="src/app.ts"  descriptors=[{"text":"TODO","priority":1},{"text":"FIXME","priority":0}]

# Find TODO, FIXME, and HACK comments
todoComments  file="src/app.ts"  descriptors=[{"text":"TODO","priority":2},{"text":"FIXME","priority":1},{"text":"HACK","priority":0}]

______________________________________________________________________

definitionAndBoundSpan

喜欢 definition,而且还返回所查询符号的文本跨度。有助于准确理解哪些字符构成符号。

参数类型必填说明
filestring✅文件路径(绝对或相对于cwd)
linenumber✅从1开始的行号
offsetnumber✅行上基于1的字符偏移

示例:

definitionAndBoundSpan  file="src/app.ts"  line=10  offset=5
definitionAndBoundSpan  file="src/types.ts"  line=3  offset=11

______________________________________________________________________

findSourceDefinition

导航到实际的TypeScript源代码,而不是 .d.ts 声明文件。当使用具有源映射的库时,或者当您想查看实现而不仅仅是类型声明时,这很有用。

参数类型必填说明
filestring✅文件路径(绝对或相对于cwd)
linenumber✅从1开始的行号
offsetnumber✅行上基于1的字符偏移

示例:

findSourceDefinition  file="src/app.ts"  line=10  offset=5
findSourceDefinition  file="src/services/api.ts"  line=3  offset=15

______________________________________________________________________

selectionRange

获取语义上有意义的选择范围,以便进行智能扩展/收缩选择。返回表示逐渐增大的语法构造(表达式→ 声明→ 块→ 功能)。

参数类型必填说明
filestring✅文件路径(绝对或相对于cwd)
locations{line: number, offset: number}[]✅用于获取选择范围的位置数组

示例:

selectionRange  file="src/app.ts"  locations=[{"line":10,"offset":5}]
selectionRange  file="src/app.ts"  locations=[{"line":10,"offset":5},{"line":20,"offset":10}]

______________________________________________________________________

format

根据TypeScript的格式化规则格式化一系列代码。应用一致的缩进、间距和换行。

参数类型必填说明
filestring✅文件路径(绝对或相对于cwd)
linenumber✅从1开始的范围起始线
offsetnumber✅基于1的起始字符偏移
endLinenumber✅基于1的范围结束线
endOffsetnumber✅基于1的结束字符偏移
optionsobject--格式选项(tabSize、indentSize等)
previewboolean✅如果 true,返回更改而不应用

示例:

format  file="src/app.ts"  line=1  offset=1  endLine=50  endOffset=1
format  file="src/app.ts"  line=10  offset=1  endLine=20  endOffset=1  preview=true
format  file="src/app.ts"  line=1  offset=1  endLine=100  endOffset=1  options={"tabSize":4}

______________________________________________________________________

getMoveToRefactoringFileSuggestions

将符号移动到另一个文件时,获取建议的目标文件。返回建议的新文件名和作为良好目标的现有文件。以前用这个 moveSymbol 选择最佳目标位置。

参数类型必填说明
filestring✅文件路径(绝对或相对于cwd)
startLinenumber✅声明的起始行从1开始
startOffsetnumber✅基于1的起始字符偏移
endLinenumber✅声明的基于1的结束行
endOffsetnumber✅基于1的结束字符偏移

示例:

getMoveToRefactoringFileSuggestions  file="src/app.ts"  startLine=20  startOffset=1  endLine=35  endOffset=2
getMoveToRefactoringFileSuggestions  file="src/components/Button.tsx"  startLine=1  startOffset=1  endLine=5  endOffset=2

______________________________________________________________________

getSupportedCodeFixes

返回具有可用自动修复的所有错误代码的列表。在调用之前将其用作发现工具 getCodeFixes -它告诉您tsserver可以修复哪些错误代码。可以选择将查询范围限定到特定文件的项目。

参数类型必填说明
filestring--可选文件路径(相对于cwd的绝对或相对路径)。如果提供,则范围为文件的项目。

示例:

# Get all fixable error codes globally
getSupportedCodeFixes

# Get fixable error codes scoped to a specific project
getSupportedCodeFixes  file="src/app.ts"

______________________________________________________________________

mapCode

将AI生成的代码片段映射到一个文件中,用名称替换匹配的声明或附加新的声明。专为AI代码生成工作流程而设计,您可以在不重复声明的情况下将新代码合并到现有文件中。

参数类型必填说明
filestring✅文件路径(绝对或相对于cwd)
contentsstring[]✅要映射到文件中的代码片段。每个都是独立解析的。函数和类按名称匹配。
focusLocationsobject[][]--嵌套数组 {start, end} span(基于1的行/偏移量)用于启用基于名称的匹配。若无此项,代码将始终附加至文件末尾。
previewboolean✅如果 true,返回更改而不应用

匹配是如何工作的:

  • 没有 focusLocations → 代码始终附加到文件末尾(未尝试匹配)
  • 随着 focusLocations → TypeScript在指向的作用域中搜索具有匹配名称的声明
  • 匹配工作适用于: 函数、类、方法、接口(具有 .name 财产)
  • 匹配不适用于: const/let/var 声明(VariableStatement 没有 .name)
  • 找到匹配项后,将替换从第一个匹配语句到最后一个匹配语句的范围
  • 当未找到匹配项时,代码将附加到作用域的末尾

限制:

  • 与多人通话 contents 条目只应用第一个匹配项——每个声明调用一次以替换多个
  • const/let/var 不支持替换;改用标准文件编辑

示例:

# Replace an existing function (focusLocations enables name-based matching)
mapCode  file="src/utils.ts"  contents=["export function add(a: number, b: number, c = 0) { return a + b + c; }"]  focusLocations=[[{"start":{"line":1,"offset":1},"end":{"line":1,"offset":1}}]]

# Append a new function (no focusLocations — always appends)
mapCode  file="src/utils.ts"  contents=["export function multiply(a: number, b: number) { return a * b; }"]

# Preview before applying
mapCode  file="src/utils.ts"  contents=["export function add(a: number, b: number) { return a + b; }"]  focusLocations=[[{"start":{"line":1,"offset":1},"end":{"line":1,"offset":1}}]]  preview=true

支持的语言和框架

ts-mcp-server 适用于TypeScript语言服务理解的任何项目:

  • TypeScript (.ts, .tsx, .mts, .cts)
  • JavaScript (.js, .jsx, .mjs, .cjs)
  • 反应 / Next.js / 混音 / 星的
  • 视图 (脚本块)
  • Node.js / 快速 / 快车 / NestJS
  • Angular
  • 斯维尔特 (脚本块)
  • 电子
  • React Native
  • 单体仓库 (Turborepo、Nx、Lerna、pnpm工作区)

如果你的项目有 tsconfig.json (或 jsconfig.json),它工作。

系统要求

要求版本
Node.js22或更高版本(当前LTS)
TypeScript6.x(作为依赖项自动安装)
操作系统Windows、macOS、Linux

不需要额外的依赖关系或全局工具。服务器捆绑了它需要的一切。

常见问题解答

它在没有 tsconfig.json? 对。TypeScript会创建一个推断的项目,但显式配置会给出更好的结果。

它更新了吗 package.json 还是非代码文件? 否。它更新Types/JavaScript导入和导出语句,以及中与路径相关的条目 tsconfig.json (files, include, exclude, paths).

我可以在纯JavaScript项目中使用它吗? 对。添加一个 jsconfig.json (相当于 tsconfig.json 和 allowJs: true)服务器将发现您的项目。

它是否适用于路径别名(@/components/...)? 对。 tsserver 解析中定义的路径别名 tsconfig.jsons paths 和 baseUrl 设置。

输出是否被修改或格式化? 不是的。每个工具都会返回未经修改的原始数据 tsserver 响应序列化为JSON。没有任何内容被截断、简化、分组或过滤。

工具与能力

工具数量

39

资源数量

0

提示词数量

0

能力标签

代码重构TypeScript本地部署代码智能AI编程辅助开发工具

支持客户端

ClaudeCursorWindsurfVS Code

数量来自来源目录的标注,具体工具清单以官方文档为准。

典型使用场景

让助手直接读代码

把仓库、提交记录和 issue 交给模型检索,补全和重构时不用来回复制文件。

在对话里跑命令

触发构建、测试和脚本,执行结果直接回到上下文,省去切终端。

接进开发流程

把 PR、CI 状态和代码审查接进助手,减少在几个工具之间跳。

选择建议

值得选的地方

  • 工具数量 39 个,一次接入能覆盖的操作比单点工具更全。
  • 有现成的安装命令,不用自己找入口,照着跑就能起服务。
  • 已经适配 Claude、Cursor、Windsurf,换客户端不用重新研究配置。

先想清楚的地方

  • stdio 方式要求本地装好 Node.js,换机器要重新装一遍。
  • 第三方目录整理,版本更新和行为细节以官方仓库为准。

更适合

  • 需要在开发工具场景里让模型直接调用外部能力的人。
  • 已经在用 Claude 的用户,接入路径最短。
  • 想先快速试一下、能接受在本地跑服务的人。

不太适合

  • 完全不想在本地装环境的人。
  • 需要厂商级 SLA 和技术支持的生产环境。

同类对比

5 个同类
MCP Server工具数传输方式安装命令收录来源最后核验
Ts MCP Server

MCP World · 本页

39stdio有1 个2026-05-17
Git 838e2ec1

MCP World

12stdio有2 个2026-05-17
Markitdown MCP 2c653a5f

MCP World

1stdio有1 个2026-05-17
Context7 MCP C671e75a

MCP World

0stdio有1 个2026-05-17
Context7 831acf40

MCP World

0stdio有1 个2026-05-17

按同分类和工具数量挑出最接近的几条,字段以各自详情页为准。

常见问题

5 条

Ts MCP Server 怎么安装?

公开资料给出的安装命令是 npx ts-mcp-server,运行环境为 Node.js。装完后按客户端要求写进 MCP 配置,重启客户端生效。

Ts MCP Server 怎么在 Claude Desktop、Cursor 里配置?

它是stdio 本地进程,客户端配置里要写启动命令和参数,运行环境是 Node.js;保存后完全退出客户端再打开,配置才会生效。

Ts MCP Server 收费吗?

本站只整理公开资料,不代收费用,也没有标注具体价格。是否收费取决于服务本身和背后的接口额度,正式使用前按官方说明确认。

Ts MCP Server 需要 API Key 吗?

公开资料标注为无需认证,装好就能连;如果实际调用时报鉴权错误,按官方文档补上凭据。

Ts MCP Server 支持哪些客户端?

公开资料标注支持 Claude、Cursor、Windsurf、VS Code;其他客户端只要能配置 MCP Server,也能用同样的命令或地址接入。

来源信息

继续浏览同类 MCP