Build elegant TypeScript MCP servers with tools resources prompts logging and SSE support
LiteMCP is a TypeScript-based framework designed to simplify the process of building Model Context Protocol (MCP) servers, making it easier for developers to integrate various tools and resources into their AI applications. By defining simple tools, resources, and prompts, LiteMCP enables seamless interaction between AI applications like Claude Desktop, Continue, Cursor, and other MCP clients.
LiteMCP offers several core features that enhance the capabilities of MCP servers:
Simplified Tool Definition: Tools in MCP allow servers to expose executable functions. With LiteMCP, you can easily define a tool like "add" which takes two numbers and returns their sum.
server.addTool({
name: "add",
description: "Add two numbers",
parameters: z.object({
a: z.number(),
b: z.number(),
}),
execute: async (args) => {
return args.a + args.b;
},
});
Resource Management: Resources represent data available to clients and include file contents, log files, binary data, etc. Each resource is identified by a unique URI.
server.addResource({
uri: "file:///logs/app.log",
name: "Application Logs",
mimeType: "text/plain",
async load() {
return { text: await readLogFile() };
},
});
Prompt Configuration: Prompts allow you to define reusable templates and workflows. They help standardize common interactions between LLMs.
server.addPrompt({
name: "git-commit",
description: "Generate a Git commit message",
arguments: [
{
name: "changes",
description: "Git diff or description of changes",
required: true,
},
],
load: async (args) => {
return `Generate a concise but descriptive commit message for these changes:\n\n${args.changes}`;
},
});
Built-in Logging: The logger
object in LiteMCP allows you to send log messages from your server to the client.
server.addTool({
name: "download",
description: "Download a file from a URL",
parameters: z.object({
url: z.string(),
}),
execute: async (args) => {
server.logger.info("Downloading file", { url: args.url });
// ...
server.logger.info("Downloaded file", { url: args.url });
return response;
},
});
CLI for Testing and Debugging: The mcp-cli
tool provides a convenient way to test and debug your server from the terminal.
SSE Transport Support: You can also run your server with Server-Sent Events (SSE) mode, which listens on /sse
.
graph TD
A[AI Application] -->|MCP Client| B[MCP Protocol]
B --> C[MCP Server]
C --> D[Data Source/Tool]
style A fill:#e1f5fe
style C fill:#f3e5f5
style D fill:#e8f5e8
MCP Client | Resources | Tools | Prompts | Status |
---|---|---|---|---|
Claude Desktop | ✅ | ✅ | ✅ | Full Support |
Continue | ✅ | ✅ | ✅ | Full Support |
Cursor | ❌ | ✅ | ❌ | Tools Only |
This matrix ensures compatibility with leading AI applications, enabling a wide range of integrations and use cases.
To get started quickly, you can install LiteMCP using npm:
npm install litemcp zod
Then, create your server definition file (e.g., server.js
):
import { LiteMCP } from "litemcp";
import { z } from "zod";
const server = new LiteMCP("demo", "1.0.0");
server.addTool({
name: "add",
description: "Add two numbers",
parameters: z.object({
a: z.number(),
b: z.number(),
}),
execute: async (args) => {
return args.a + args.b;
},
});
server.start();
Imagine an application where a user needs to access and manipulate files. Using LiteMCP, you can easily define resources for file management:
server.addResource({
uri: "file:///logs/app.log",
name: "Application Logs",
mimeType: "text/plain",
async load() {
return { text: await readLogFile() };
},
});
This resource allows any MCP client, including AI applications like Continue or Cursor, to access and display the log file content.
Consider a workflow where you need to execute various tools. You can define tools that perform specific actions:
server.addTool({
name: "download",
description: "Download a file from a URL",
parameters: z.object({
url: z.string(),
}),
execute: async (args) => {
server.logger.info("Downloading file", { url: args.url });
// ...
server.logger.info("Downloaded file", { url: args.url });
return response;
},
});
These tools can be invoked by AI applications, ensuring that the required tasks are executed and providing visibility through logs.
LiteMCP integrates seamlessly with key MCP clients:
Claude Desktop: Supports full resource, tool, and prompt integration.
Continue: Full support for resources and tools but lacks native prompt functionality.
Cursor: Limited to tool execution; no resource or prompt support.
Performance-wise, LiteMCP ensures efficient handling of requests. It supports various transport modes, including WebSockets, ensuring smooth communication between the server and MCP clients.
Compatibility with different AI workflows is a key feature. The framework adapts to diverse use cases, from simple file management tasks to complex tool executions, providing robust support across multiple platforms.
You can customize your configuration through environment variables:
{
"mcpServers": {
"[server-name]": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-[name]"],
"env": {
"API_KEY": "your-api-key"
}
}
}
}
Additional security measures include token authentication, rate limiting, and strict validation of incoming requests.
Q: Can LiteMCP be used with multiple MCP clients simultaneously?
Q: How do I handle errors in my tools and resources?
Q: What is the default transport mode used by LiteMCP servers?
stdio
, but you can switch to SSE or other modes supported by your client configuration.Q: How do I ensure security when using LiteMCP in production?
Q: Can LiteMCP be extended with custom tools or resources?
If you have any questions about development guidelines or are interested in contributing to the project:
Feel free to contribute documentation, tools, and resources to enhance LiteMCP.
Explore the broader MCP ecosystem to discover other projects building on this protocol:
For more information on the Model Context Protocol, visit the official website at: Model Context Protocol Website
By leveraging LiteMCP, developers can build powerful AI applications that integrate seamlessly with a wide range of tools and resources. Whether you're working on file management, tool execution, or complex workflows, LiteMCP provides the foundation to create robust and scalable solutions.
Learn to connect to MCP servers over HTTP with Python SDK using SSE for efficient protocol communication
Next-generation MCP server enhances documentation analysis with AI-powered neural processing and multi-language support
Python MCP client for testing servers avoid message limits and customize with API key
Discover easy deployment and management of MCP servers with Glutamate platform for Windows Linux Mac
Expose Chicago Public Schools data with a local MCP server accessing SQLite and LanceDB databases
Learn how to use MCProto Ruby gem to create and chain MCP servers for custom solutions