ModelFetch MCP Server SDK for TypeScript
Build and deploy runtime-agnostic MCP server apps with the ModelFetch TypeScript SDK, running anywhere TypeScript/JavaScript is supported.
Overview
ModelFetch MCP Server SDK for TypeScript is a developer-focused toolkit for building Model Context Protocol (MCP) server applications in TypeScript and JavaScript. It provides a lightweight, runtime-agnostic layer that helps you expose model-backed capabilities (models, tools, and workflows) over a standard MCP-compatible interface so your apps can run on Node.js, Deno, Cloudflare Workers, or any environment that supports TypeScript/JavaScript.
The SDK is useful when you want a consistent server-side surface for multiple model providers, shared tooling (e.g., retrieval tools, sanitizers, or toolkits), or when you need to deploy model-driven endpoints across different runtimes without rewriting request handling logic. It includes TypeScript types, request/response adapters, and helper primitives to register models and tools and to handle streaming and non-streaming invocations uniformly.
Features
- Runtime-agnostic MCP server primitives (Node, Deno, Workers, and other JS runtimes)
- TypeScript-first SDK with type definitions for safe developer experience
- Simple adapters to integrate with Express, Fastify, or native fetch handlers
- Support for registering models and tools and exposing them via MCP
- Consistent handling for streaming and non-streaming model outputs
- Environment-friendly configuration (works well with serverless and edge functions)
- Example apps and templates to bootstrap MCP services quickly
Installation / Configuration
Install the package from npm (replace with your package registry if required):
# npm
# yarn
# pnpm
Basic environment variables used by typical deployments:
- PORT — HTTP port to listen on (Node)
- MF_API_KEY — API key for any external model provider you wire up
- MF_BACKEND — optional backend selector (e.g., “openai”, “local”, “custom”)
Example .env:
PORT=3000
MF_API_KEY=sk-xxxxxx
MF_BACKEND=openai
TypeScript configuration (tsconfig.json) should target a modern ES runtime for best compatibility:
Quick Start Examples
Minimal Node + Express example (TypeScript):
;
; // handler adapter from SDK
// register your models/tools via SDK exports (pseudo-code)
;
"default", ;
"search", ;
;
;
// mount the MCP handler at /mcp
"/mcp", ;
;
port,;
Cloudflare Worker (Edge) example:
;
; // returns a function that accepts Request
"fetch",;
The SDK supplies adapters so the same registered models/tools are reachable regardless of how the HTTP surface is mounted.
Available Resources
- GitHub repository: https://github.com/phuctm97/modelfetch/ — source code, issues, and examples
- Examples folder (in repo) — starter projects for Node, Deno, and Worker deployments
- TypeScript types — included in the package for autocompletion and compile-time checks
- API reference — check the repository README or docs directory for the latest export list and adapters
- Issues/Discussions — use the GitHub repo to report bugs or request features
Use Cases
- Unified model gateway: expose a single MCP-compatible endpoint that routes requests to multiple model providers depending on configuration or tenant.
- Serverless model proxies: deploy small MCP services as serverless functions or edge workers for low-latency inference or middleware logic (e.g., prompt sanitization, observability).
- Tool orchestration: register retrieval tools, search connectors, or database lookup functions that models can call during generation, without coupling to a single runtime.
- Local development and testing: run a local MCP server that simulates production model responses, record/playback model interactions, or run integration tests against a stable MCP surface.
- Multi-runtime deployments: write your handler logic once (register models, tools, and workflows) and deploy it to Node, edge, or serverless runtimes with minimal changes.
Tips for Getting Started
- Start with the repository examples to see runtime-specific adapters in action.
- Keep model registration centralized (e.g., a single bootstrap file) so the same configuration applies across runtimes.
- Use environment variables and secrets managers to avoid embedding API keys in source code.
- Leverage TypeScript types exported by the SDK to reduce runtime errors when wiring models and tools.
This SDK is intended for developers who want a consistent, portable MCP surface for their model-driven services. Refer to the repository examples and API docs for the concrete exported functions and adapter helpers.