Labsco
MCP SERVER

TypeScript MCP Server

by AndyLiner13

Drive tsserver from the client: rename a symbol or move a whole folder with every import rewritten, extract functions, constants and types, read diagnostics, and walk the call hierarchy in both directions.

Code Generation, Scaffolding & MigrationVerified
Summary
The refactors are tsserver's own, so an import rewrite is the compiler's answer rather than a search and replace that happens to work.

It shows in what can be done safely: moving a folder updates every import pointing inside it, and moving a symbol creates the destination file when it is missing. The edit tools take a preview switch, so an agent can read the edits before they land. The discovery tools matter as much as the edits — what refactors apply here, which error codes are fixable, where a symbol could reasonably move — because they replace the guessing that otherwise precedes a failed refactor. mapCode is the one to read closely before using: without focusLocations it does not attempt to match anything and always appends to the end of the file.

What it is

A TypeScript language-service bridge of 40 tools — refactors, diagnostics, navigation, completion and formatting — over files that belong to a tsconfig.json project.

What you get
  • Renames that reach the whole project: rename for a symbol at a line and offset, and getEditsForFileRename, which moves a file or an entire folder and updates every import referencing what is inside it, across .ts, .tsx, .js and .jsx.
  • Refactors with a preview switch — extractFunction, extractConstant, extractType, inlineVariable, inferReturnType, and moveSymbol, which rewires imports and creates the target file when it does not exist.
  • Discovery before you refactor: getApplicableRefactors reports what is possible at a position and why an action may not apply, and getMoveToRefactoringFileSuggestions proposes both a new filename and existing destinations.
  • Diagnostics and fixes: getDiagnostics for errors, warnings, unused variables, unused imports and unreachable code, getSupportedCodeFixes for which error codes are fixable at all, getCodeFixes for a specific range, and getCombinedCodeFix to apply one fix across an entire file in a single action.
  • Navigation: definition, definitionAndBoundSpan, typeDefinition, implementation, findSourceDefinition for the real source behind a .d.ts, references across the project, fileReferences for the reverse dependency graph of one file, navto for workspace-wide symbol search and navtree for a single file's structure.
  • Call hierarchy in both directions — prepareCallHierarchy first, then provideCallHierarchyIncomingCalls for who calls this and provideCallHierarchyOutgoingCalls for what it calls.
  • Editor-grade reads: quickinfo for hover type and JSDoc, completionInfo with completionEntryDetails, signatureHelp inside a call's parentheses, provideInlayHints for inferred types, documentHighlights distinguishing reads from writes, selectionRange for structural expand and shrink, and getOutliningSpans for folding regions.
  • organizeImports, which sorts, coalesces and removes unused imports in one pass; format over a range or a whole file; docCommentTemplate for a JSDoc skeleton with @param and @returns; todoComments for the markers you name in a descriptors array; and projectInfo for the tsconfig path and file list.
  • mapCode, for inserting generated code: with focusLocations TypeScript matches declarations by name, and without them the code is appended to the end of the file.
Requirements

A TypeScript or JavaScript project with a tsconfig.json — getDiagnostics and organizeImports both require the file to belong to one, and getSupportedCodeFixes needs a file path to establish project context or tsserver throws 'No Project'. Positions given as 1-based line and offset. noUnusedLocals or noUnusedParameters enabled in tsconfig, if you want unused-code diagnostics to appear at all.

Setup effort

One command — npx ts-mcp-server