mcp-serverless
Serverless implementation of the Model Context Protocol (MCP)
Documentation
MCP Serverless
A serverless implementation for the Model Context Protocol (MCP) architecture that enables tool management through a clean interface.
Overview
This package provides a serverless implementation of the MCP server that allows you to:
- Register and manage tools
- Handle tool-related requests
- Create in-memory client-server connections
- Extend request with context to enable credential transmission from clients
Installation
npm install @tilfin/mcp-serverlessUsage
Tool Registration and create a client for service implements
import { createService, ToolManager } from '@tilfin/mcp-serverless';
// Create a tool manager
const toolManager = new ToolManager();
// Register tools
toolManager.registerTools([
{
name: 'calculator',
description: 'Performs basic arithmetic operations',
inputSchema: {
type: 'object',
properties: {
operation: { type: 'string' },
numbers: { type: 'array', items: { type: 'number' } }
},
required: ['operation', 'numbers']
},
toolFunction: async (params, ctx) => {
if (ctx.apiKey !== 'xyz') throw new Error('Invalid API Key');
let result;
if (params.operation === 'add') {
result = params.numbers.reduce((sum, n) => sum + n, 0);
}
return { result };
}
}
]);
// Create a serverless client
const client = createService(toolManager);
// List available tools
const toolsList = await client.listTools();
// Call a tool
try {
const result = await client.callTool({
name: 'calculator',
arguments: {
operation: 'add',
numbers: [1, 2, 3]
}
});
} catch (err) {
// raise Invalid API Key error
}
// Call a tool with context
const result = await client.callTool({
name: 'calculator',
arguments: {
operation: 'add',
numbers: [1, 2, 3]
},
ctx: { apiKey: 'xyz' }
});API Reference
`ToolManager` class
Manages the registration and handling of tools.
`Tool` Interface
Tools must implement the following interface:
interface Tool {
name: string;
description: string;
inputSchema: ToolInput;
toolFunction: (args: CallToolRequestArguments, ctx: CallToolRequestContext) => Promise;
}`createServer(serverInfo, toolManager)`
Creates an MCP server with the given tool manager.
`createService(toolManager)`
Creates an in-memory client-server setup for serverless operation.
Examples
Standard I/O Transport
The package includes examples for using the stdio transports for both client and server communication:
- `StdioClientTransport`: Allows clients to communicate with servers over standard input/output
- `StdioServerTransport`: Enables servers to handle requests through standard input/output
Check out the example implementation:
- Client: stdio_client.mjs
- Server: stdio_server.mjs
Frequently asked questions
What is mcp-serverless?
mcp-serverless is Serverless implementation of the Model Context Protocol (MCP)
How do I install mcp-serverless?
Open the GitHub repository and follow its README. Most MCP servers are added to your client's MCP config, then called by your agent.
Is mcp-serverless open source?
Yes — it is hosted on GitHub at https://github.com/tilfin/mcp-serverless and has 1 stars.
Related MCP tools
🍒 Cherry Studio is a desktop client that supports for multiple LLM providers. Built for the Model Context Protocol to enhance AI capabilities.
Enhanced ChatGPT Clone: Features Agents, MCP, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini...
FastGPT is a knowledge-based platform built on the LLMs, offers a comprehensive suite of out-of-the-box capabilities such as data processing, RAG retrieval, ...
Composio equips your AI agents & LLMs with 100+ high-quality integrations via function calling for the Model Context Protocol. Enhance AI assistants with powerf
📦 Repomix is a powerful tool that packs your entire repository into a single, AI-friendly file. Perfect for when you need to feed your codebase to Large Lan...
AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Ag...
Run your own MCP server? See who uses it and what to fix.
Measure it with TrackMCP