Cover image
Try Now
2025-04-12

一个模型上下文协议(MCP)服务器,可帮助AI代码编辑器在代码库中查找Typescript符号定义。当您需要在打字稿项目中找到导入符号,类,接口或功能的原始定义时,此工具特别有用。

3 years

Works with Finder

1

Github Watches

1

Github Forks

0

Github Stars

TypeScript Definition Finder MCP Server

smithery badge

A Model Context Protocol (MCP) server that helps AI code editors find TypeScript symbol definitions in your codebase. This tool is particularly useful when you need to locate the original definition of imported symbols, classes, interfaces, or functions in a TypeScript project.

Features

  • Finds original definitions of TypeScript symbols
  • Works with imported symbols from external packages
  • Returns both the definition location and code snippet
  • Supports stdio interface for seamless integration with AI code editors

Prerequisites

  • TypeScript project with typescript dependency installed
  • Node.js for running the server

Installation & Usage

This is a Model Context Protocol (MCP) stdio server that requires access to your local filesystem to find TypeScript definitions.

Installing via Smithery

To install TypeScript Definition Finder MCP for Claude Desktop automatically via Smithery:

npx -y @smithery/cli install @runninghare/typescript-definition-finder-mcp --client claude

Running the MCP Server

To use the MCP server:

  1. Ensure your project has TypeScript installed as a dependency
  2. Run the following command in your project directory:
npx -y ts-def-mcp@latest

You can integrate this command with various AI code editors that support MCP:

  • Claude Desktop
  • Cursor
  • Windsurf
  • Roo Cline Editor

Important Note: Due to the local filesystem access requirements, Docker + WebSocket solutions will not work. Please ignore the installation guide on https://smithery.ai/server/@runninghare/typescript-definition-finder-mcp.

Tool Description

The server provides a find_typescript_definition tool with the following capabilities:

  • Tool Name: find_typescript_definition
  • Trigger Command: /ts-def (Useful in ‘Cursor’ if you want to force AI editor to find the referenced symbol definition)
  • Purpose: Locates the original definition of TypeScript symbols in your codebase

Input Parameters

The tool requires three parameters:

  1. file_path (string):

    • The absolute path to the current TypeScript file
    • Example: /path/to/your/project/src/index.ts
  2. symbol (string):

    • The TypeScript symbol (variable, class name, interface, type, etc.) you want to find the definition of
    • Must be present in the line_content
    • Example: StdioServerTransport, MyClass, interface1
  3. line_content (string):

    • The entire line containing the symbol you want to find the definition of
    • Used to locate both the line number in the file and the exact position of the symbol
    • Must contain the symbol exactly as specified

Examples

  1. Finding an Imported Symbol Definition

Given this import statement:

import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";

To find the definition of StdioServerTransport, you would use:

{
  "file_path": "~/my-mcp-project/src/index.ts",
  "symbol": "StdioServerTransport",
  "line_content": "import { StdioServerTransport } from \"@modelcontextprotocol/sdk/server/stdio.js\";"
}
  1. Finding a Local Symbol Definition

For a local class usage:

class MyService {
  private transport: StdioServerTransport;
}

To find the definition of StdioServerTransport, use:

{
  "file_path": "/path/to/project/src/service.ts",
  "symbol": "StdioServerTransport",
  "line_content": "  private transport: StdioServerTransport;"
}

Response Format

The tool returns a JSON response containing:

  • The file path where the definition was found
  • The line number of the definition
  • The actual code snippet of the definition

Cursor Calling Example

MCP Input:

{
  "file_path": "/Users/rossz/workspace/ai-tools/mcp/ts-def-mcp/src/index.ts",
  "symbol": "SSEServerTransport",
  "line_content": "import { SSEServerTransport } from '@modelcontextprotocol/sdk/server/sse.js';"
}

MCP Output:

[
  {
    "file": "/Users/rossz/workspace/ai-tools/mcp/ts-def-mcp/node_modules/@modelcontextprotocol/sdk/dist/esm/server/sse.d.ts",
    "type": "Definition",
    "location": "Line 9, Column 22",
    "codeSnippet": "   8    */\n   9 > export declare class SSEServerTransport implements Transport {\n  10 +     private _endpoint;\n  11 +     private res;\n  12 +     private _sseResponse?;\n  13 +     private _sessionId;\n  14 +     onclose?: () => void;\n  15 +     onerror?: (error: Error) => void;\n  16 +     onmessage?: (message: JSONRPCMessage) => void;\n  17 +     /**\n  18 +      * Creates a new SSE server transport, which will direct the client to POST messages to the relative or absolute URL identified by `_endpoint`.\n  19 +      */\n  20 +     constructor(_endpoint: string, res: ServerResponse);\n  21 +     /**\n  22 +      * Handles the initial SSE connection request.\n  23 +      *\n  24 +      * This should be called when a GET request is made to establish the SSE stream.\n  25 +      */\n  26 +     start(): Promise<void>;\n  27 +     /**\n  28 +      * Handles incoming POST messages.\n  29 +      *\n  30 +      * This should be called when a POST request is made to send a message to the server.\n  31 +      */\n  32 +     handlePostMessage(req: IncomingMessage, res: ServerResponse, parsedBody?: unknown): Promise<void>;\n  33 +     /**\n  34 +      * Handle a client message, regardless of how it arrived. This can be used to inform the server of messages that arrive via a means different than HTTP POST.\n  35 +      */\n  36 +     handleMessage(message: unknown): Promise<void>;\n  37 +     close(): Promise<void>;\n  38 +     send(message: JSONRPCMessage): Promise<void>;\n  39 +     /**\n  40 +      * Returns the session ID for this transport.\n  41 +      *\n  42 +      * This can be used to route incoming POST requests.\n  43 +      */\n  44 +     get sessionId(): string;\n  45   }\n"
  }
]
2025-04-12_17-06-42

Development

This project was created using bun init in bun v1.2.2. Bun is a fast all-in-one JavaScript runtime.

Running in Development Mode

For development, you can run the server directly using Bun:

bun run src/index.ts

License

[Add your license information here]

Contributing

[Add contribution guidelines here]

相关推荐

  • NiKole Maxwell
  • I craft unique cereal names, stories, and ridiculously cute Cereal Baby images.

  • Bora Yalcin
  • Evaluator for marketplace product descriptions, checks for relevancy and keyword stuffing.

  • Joshua Armstrong
  • Confidential guide on numerology and astrology, based of GG33 Public information

  • https://suefel.com
  • Latest advice and best practices for custom GPT development.

  • Callycode Limited
  • A geek-themed horoscope generator blending Bitcoin prices, tech jargon, and astrological whimsy.

  • Alexandru Strujac
  • Efficient thumbnail creator for YouTube videos

  • Emmet Halm
  • Converts Figma frames into front-end code for various mobile frameworks.

  • Khalid kalib
  • Write professional emails

  • Elijah Ng Shi Yi
  • Advanced software engineer GPT that excels through nailing the basics.

  • Beniyam Berhanu
  • Therapist adept at identifying core issues and offering practical advice with images.

  • https://maiplestudio.com
  • Find Exhibitors, Speakers and more

  • apappascs
  • 发现市场上最全面,最新的MCP服务器集合。该存储库充当集中式枢纽,提供了广泛的开源和专有MCP服务器目录,并提供功能,文档链接和贡献者。

  • ShrimpingIt
  • MCP系列GPIO Expander的基于Micropython I2C的操作,源自ADAFRUIT_MCP230XX

  • OffchainLabs
  • 进行以太坊的实施

  • huahuayu
  • 统一的API网关,用于将多个Etherscan样区块链Explorer API与对AI助手的模型上下文协议(MCP)支持。

  • deemkeen
  • 用电源组合控制您的MBOT2:MQTT+MCP+LLM

    Reviews

    5 (1)
    Avatar
    user_owcjUcdg
    2025-04-16

    The TypeScript Definition Finder MCP by runninghare is an incredibly useful tool for any TypeScript developer. It simplifies the process of finding and managing type definitions, saving you valuable time. The GitHub repository is well-documented, making it easy to integrate into your projects. Highly recommend checking it out: https://github.com/runninghare/typescript-definition-finder-mcp