A Model Context Protocol (MCP) tool for providing TypeScript type definitions from npm packages.
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.
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
- 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
You can install globally:
npm install -g typescript-type-fetcher
Or install as a project dependency:
npm install typescript-type-fetcher
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.
The tool can be used as an MCP server that provides two main functionalities:
Fetch type definitions for a specific package:
{
"tool": "typescript-types",
"args": {
"packageName": "lodash",
"version": "4.17.21", // optional
"fuzzyMatch": true // optional
}
}
Access package information using the resource URI format:
typescript-package://{name}@{version}
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"
}
{
"name": "package-name",
"version": "1.0.0",
"fileCount": 5,
"success": true,
"error": null
}
- Node.js >= 14.16
# 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 type to be specified]