typescript-type-fetcher

1.0.3 • Public • Published

TypeScript Type Fetcher

A Model Context Protocol (MCP) tool for providing TypeScript type definitions from npm packages.

Description

TypeScript Type Fetcher is a Model Context Protocol (MCP) service that provides TypeScript type definitions from npm packages. It runs as an MCP server that communicates through standard input/output (stdio), making it compatible with any MCP-enabled development environment.

MCP Service Details

This tool implements an MCP server that:

  • Communicates via stdio using the MCP protocol
  • Provides a tool endpoint for fetching TypeScript types
  • Offers a resource endpoint for package information
  • Handles errors with meaningful messages and package suggestions

The server exposes:

  • Tool: typescript-types - For fetching type definitions
  • Resource: typescript-package://{name}@{version} - For package information

Features

  • Fetch TypeScript type definitions from any npm package
  • Support for specific package versions
  • Fuzzy matching for package names with suggestions
  • Direct integration with MCP-compatible environments

Installation

You can install globally:

npm install -g typescript-type-fetcher

Or install as a project dependency:

npm install typescript-type-fetcher

Usage

Running with npx

You can run the tool directly using npx:

npx typescript-type-fetcher

This will start the MCP server that communicates through stdio. Note that this tool is designed to be used as an MCP service, so it expects MCP protocol messages through stdin and responds through stdout.

MCP Integration

The tool can be used as an MCP server that provides two main functionalities:

1. TypeScript Types Tool

Fetch type definitions for a specific package:

{
  "tool": "typescript-types",
  "args": {
    "packageName": "lodash",
    "version": "4.17.21",  // optional
    "fuzzyMatch": true     // optional
  }
}

2. Package Resource

Access package information using the resource URI format:

typescript-package://{name}@{version}

API Response Format

TypeScript Types Tool Response

On success:

{
  "content": [
    {
      "type": "text",
      "text": "Type definitions for package@version"
    },
    {
      "type": "text",
      "text": "// Type definition content",
      "language": "typescript"
    }
    // ... additional type files
  ]
}

On error:

{
  "error": "Error message"
}

Package Resource Response

{
  "name": "package-name",
  "version": "1.0.0",
  "fileCount": 5,
  "success": true,
  "error": null
}

Requirements

  • Node.js >= 14.16

Development

# Install dependencies
npm install

# Build the project
npm run build

# Start the server
npm start

# Watch mode during development
npm run dev

# Clean build artifacts
npm run clean

License

[License type to be specified]

Readme

Keywords

none

Package Sidebar

Install

npm i typescript-type-fetcher

Weekly Downloads

17

Version

1.0.3

License

none

Unpacked Size

15.9 kB

Total Files

5

Last publish

Collaborators

  • shinychang