MCP Framework provides a robust architecture for developing Model Context Protocol (MCP) servers using TypeScript. It offers automatic directory-based discovery for tools, resources, and prompts, allowing developers to define MCP components elegantly with full type safety. The framework includes multiple transport support, authentication for SSE endpoints, and is built on the official MCP SDK to ensure compatibility and performance.
MCP Framework simplifies the development of Model Context Protocol servers by providing a structured, TypeScript-first approach. The framework handles the complex aspects of MCP server implementation, allowing you to focus on building your tools, resources, and prompts.
The easiest way to get started with MCP Framework is by using its CLI:
# Install the framework globally
npm install -g mcp-framework
# Create a new MCP server project
mcp create my-mcp-server
# Navigate to your project
cd my-mcp-server
After creating a project, you'll have a directory structure that follows MCP Framework conventions:
src/tools/
- Directory for your tool implementationssrc/prompts/
- Directory for your prompt definitionssrc/resources/
- Directory for your resource implementationsThe CLI makes it easy to add new components to your project:
# Add a new tool
mcp add tool my-tool-name
# Add a new prompt
mcp add prompt my-prompt-name
# Add a new resource
mcp add resource my-resource-name
Each command generates the appropriate TypeScript files with the necessary base classes and structure.
To build your MCP server:
npm run build
This compiles your TypeScript code into JavaScript in the dist/
directory.
MCP Framework supports several environment variables for configuration:
MCP_ENABLE_FILE_LOGGING
- Enable logging to files (true/false, default: false)MCP_LOG_DIRECTORY
- Directory where log files will be stored (default: logs)MCP_DEBUG_CONSOLE
- Display debug level messages in console (true/false)When creating a project, you can specify different transport options:
# Create with HTTP transport
mcp create my-server --http --port 1337 --cors
Options:
--http
- Use HTTP transport instead of default stdio--port
- Specify HTTP port (default: 8080)--cors
- Enable CORS with wildcard (*) accessAdd this configuration to your Claude Desktop config file:
MacOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%/Claude/claude_desktop_config.json
{
"mcpServers": {
"my-mcp-server": {
"command": "node",
"args": ["/absolute/path/to/my-mcp-server/dist/index.js"]
}
}
}
After publishing your MCP server as an npm package:
{
"mcpServers": {
"my-mcp-server": {
"command": "npx",
"args": ["my-mcp-server"]
}
}
}
mcp create
npm run build