Fastify MCP Server
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
đ Fastify MCP Server
High-performance MCP (Model Context Protocol) server built with Fastify, TypeScript, and functional programming principles. Production-ready with authentication, metrics, and auto-discovery capabilities.
đ¯ About This Project
Fastify MCP Server is a production-grade implementation of the Model Context Protocol (MCP) specification, designed for AI agents and LLM applications. Built with modern TypeScript and functional programming paradigms, it provides a robust foundation for AI-powered applications requiring secure, scalable MCP server capabilities.
đ Key Benefits
⥠Lightning Fast: Built on Fastify - the fastest Node.js web framework
đ Enterprise Security: Bearer token authentication and secure session management
đ Production Ready: Kubernetes health checks, metrics endpoints, and monitoring
đ§Š Auto-Discovery: Automatic registration of tools, resources, and prompts
đĄī¸ Type Safe: Full TypeScript support with Zod validation
đ¯ Functional: Purely functional programming approach for reliability
Related MCP server: Python MCP Server Kit
đ Table of Contents
⨠Features
đī¸ Fastify-powered - Lightning-fast HTTP server with TypeScript support
đ§ MCP Protocol - Full Model Context Protocol implementation with tools, resources, and prompts
đĄī¸ Secure Authentication - Bearer token middleware for MCP server connections
đ Production Ready - Kubernetes health endpoints and metrics routes
đ§Š Modular Architecture - Auto-registration system for MCP capabilities
đ Type Safety - Zod validation with
@modelcontextprotocol/sdkđ¯ Functional Programming - Strictly functional paradigms throughout
đ Use Cases
Perfect for building:
AI Agent Platforms - Secure MCP servers for AI applications
LLM Integration - Connect language models with external tools and data
Enterprise AI - Production-ready MCP infrastructure for organizations
Developer Tools - Custom MCP servers for development workflows
API Gateways - High-performance API endpoints with MCP capabilities
Microservices - Scalable MCP services in distributed architectures
đ Why Choose This Server?
Feature | Fastify MCP Server | Other Solutions |
Performance | ⥠Fastify-based | â Express/Slower |
Type Safety | â Full TypeScript | â JavaScript only |
Security | đ Bearer tokens | â Basic auth |
Production | đ Metrics & Health | â Development only |
Architecture | đ§Š Auto-discovery | â Manual setup |
Standards | â MCP 1.0 compliant | â Custom protocols |
⥠Production Readiness
â Kubernetes - Health checks and readiness probes
â Monitoring - Built-in metrics and logging
â Security - Bearer token authentication
â Scalability - Horizontal scaling support
â Reliability - Per-session MCP isolation, automatic stale session cleanup
đī¸ Architecture
Core Components
Fastify Server - High-performance HTTP server with custom MCP plugin
MCP Transport - Injected as a Fastify plugin for seamless integration
Session Management - Handles MCP client connections and state
Auto-registration - Automatically discovers and registers MCP capabilities
Endpoints
GET /health- Kubernetes liveness probe (no auth)GET /metrics- Application metrics (no auth)POST /mcp- MCP StreamableHTTP transport (bearer auth required)
Session Management
The MCP SDK requires one Server/Protocol instance per transport, so the session manager instantiates a fresh McpServer per connection (see src/mcp/sessions.ts). Sessions are tracked by ID and reaped after 30 minutes of inactivity.
Per-session isolation - Each MCP client gets its own server instance
Activity-based timeouts - Sessions stay alive while actively used
Automatic cleanup - Stale sessions (30 min idle) removed every 5 min
Graceful shutdown - All sessions closed on server stop
Session lifecycle: create (new UUID) â reuse on subsequent requests with same mcp-session-id header â cleanup when stale.
đ Security
The server includes authentication middleware (src/middleware/auth.ts) that verifies MCP connections using a bearer token. The token is configured via the MCP_SERVER_TOKEN environment variable, ensuring secure access to the MCP server capabilities.
đ MCP Capabilities
The server automatically registers tools, resources, and prompts from their respective folders when you update the index.ts file in each directory:
đ ī¸ Tools
Active, callable functions that perform operations and return structured outputs. Perfect for:
State changes and side effects
External API calls and computations
Agentic workflows where the LLM chooses which tool to invoke
đ Resources
Read-only, structured data surfaces exposed via URI. Ideal for:
Contextual knowledge and documentation
Shared context across sessions
Binary content and large artifacts
đ Prompts
Parameterized instruction templates for reusable AI workflows. Great for:
Standardized tasks (summarization, translation, etc.)
Separating prompt engineering from application logic
Multi-step orchestrated workflows
đĄ Each capability type has detailed documentation in its respective
README.mdfile.
đ Quick Start
Prerequisites
Node.js >= 22 (recommended: 24.x LTS, see
.nvmrc)pnpm (the project ships a
pnpm-lock.yaml)Git
đĄ With nvm:
nvm usewill pick up the version pinned in.nvmrcautomatically.
Installation
git clone https://github.com/your-username/fastify-mcp-server.git
cd fastify-mcp-server
pnpm install
pnpm buildDevelopment
pnpm dev # HTTP server with hot reload (tsx watch)
pnpm mcp # Run as stdio MCP server (for Claude Desktop direct integration)
pnpm start # Production server (after pnpm build)Configuration
cp .env.example .envMCP_SERVER_PORT=9080
MCP_SERVER_HOST=localhost
MCP_SERVER_TOKEN=super-secret-token # change for non-local use
LOG_LEVEL=debugđ MCP Client Integration
Two integration paths â stdio (simplest, no server needed) or HTTP (test the production transport, auth, sessions).
Claude Desktop â stdio (recommended for local dev)
Build first: pnpm build. Then add to ~/Library/Application Support/Claude/claude_desktop_config.json:
{
"mcpServers": {
"fastify-mcp-local": {
"command": "node",
"args": ["/absolute/path/to/fastify-mcp-server/dist/mcp-stdio.js"]
}
}
}âšī¸ The logger writes to stderr by default in stdio mode, so no extra config is needed.
Claude Desktop â HTTP via mcp-remote bridge
Claude Desktop only spawns stdio processes locally. To consume the HTTP transport, bridge it with mcp-remote:
{
"mcpServers": {
"fastify-mcp-local": {
"command": "npx",
"args": [
"-y",
"mcp-remote",
"http://localhost:9080/mcp",
"--header",
"Authorization: Bearer super-secret-token"
]
}
}
}Run pnpm dev first; then quit + reopen Claude Desktop. Logs at ~/Library/Logs/Claude/mcp-server-*.log.
â ī¸
npxresolvesnodefrom PATH. If you have multiple Node versions installed via nvm, ensure your default (nvm alias default) is Node âĨ 18, ormcp-remotewill crash onundici.
cURL / Postman
curl -X POST http://localhost:9080/mcp \
-H "Authorization: Bearer super-secret-token" \
-H "Content-Type: application/json" \
-H "Accept: application/json, text/event-stream" \
-d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"curl","version":"1"}}}'In Postman: POST http://localhost:9080/mcp, Auth â Bearer Token = your MCP_SERVER_TOKEN.
đ ī¸ Development
Adding New Capabilities
Tools: Add your tool in
src/tools/and export it fromsrc/tools/index.tsResources: Add your resource in
src/resources/and export it fromsrc/resources/index.tsPrompts: Add your prompt in
src/prompts/and export it fromsrc/prompts/index.ts
The server will automatically register them on restart.
Scripts
pnpm dev # HTTP server with hot reload (tsx watch)
pnpm build # Compile TypeScript â dist/
pnpm start # Run compiled server (node dist/index.js)
pnpm mcp # Run as stdio MCP server (after build)
pnpm check # Type check without emit
pnpm lint # ESLint --fix
pnpm lint:check # ESLint, no fixes
pnpm format # Prettier --write
pnpm format:check # Prettier --check
pnpm clean # Remove dist/đĻ Tech Stack
Core Technologies
Fastify - Fast and low overhead web framework
@modelcontextprotocol/sdk - Official MCP TypeScript SDK
Zod - TypeScript-first schema validation
Pino - Super fast, all natural JSON logger
TypeScript - Type safety and modern JavaScript features
Development Tools
ESLint - Code linting
Prettier - Code formatting
tsx - TypeScript execution and watch mode
pnpm - Package manager
Keywords & Tags
mcp-server fastify typescript ai-agents llm-integration model-context-protocol nodejs api-server production-ready authentication metrics kubernetes functional-programming type-safety enterprise microservices ai-platform developer-tools
đ¤ Contributing
We welcome contributions! Please see our Contributing Guidelines for details.
Development Workflow
Fork the repository
Create a feature branch (
git checkout -b feature/amazing-feature)Commit your changes (
git commit -m 'Add amazing feature')Push to the branch (
git push origin feature/amazing-feature)Open a Pull Request
Code Quality
â TypeScript - Full type safety
â ESLint - Code quality and consistency
â Prettier - Code formatting
â Tests - Comprehensive test coverage
â Documentation - Clear and up-to-date docs
đ Resources
Documentation
MCP Specification - Official MCP documentation
Fastify Documentation - Fastify framework guide
TypeScript Handbook - TypeScript reference
Community
GitHub Discussions - Community discussions
Issues - Bug reports and feature requests
Discord - Real-time community chat
Related Projects
Model Context Protocol - Official MCP organization
Fastify Ecosystem - Fastify plugins and tools
TypeScript MCP SDK - Official TypeScript SDK
đ License
Copyright Š 2025â2026 Mustafa ONAL
This project is licensed under the MIT License - see the LICENSE file for details.
Built with â¤ī¸ using functional programming principles and modern TypeScript
đ Star This Repository
If you find this project helpful, please give it a star â on GitHub!
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelogâĻ
This server cannot be deployed
Maintenance
Related MCP Connectors
Hosted runtime for persistent agent teams, durable workflows, memory, schedules, and goals.
Memory, reflection and safety for AI agents. Hosted or local, no vector database.
Build, validate, deploy â HTTP APIs, cron jobs, webhooks and MCP tools â from your AI client.
MCP server for your apps' tools and custom tools, plus hosted AI agents and approval-gated workflows
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceEnables AI agents to securely discover, execute, and observe tools with role-based access control and audit logging. Serves tools over MCP stdio and HTTP for integration with Claude Desktop, Cursor, and other clients.1-
- AlicenseNot gradedqualityDmaintenanceEnables developers to build and deploy secure, typed Model Context Protocol servers with tools, resources, prompts, bearer-token authentication, per-tool scopes, rate limiting, and health probes over Streamable HTTP.MIT
- AlicenseNot gradedqualityBmaintenanceEnables secure exposure of internal tools to LLM clients with API-key authentication, tenant isolation, per-tool guardrails, PII scrubbing, rate limiting, audit logging, and telemetry over stdio and HTTP/SSE.MIT
- AlicenseAqualityCmaintenanceEnables developers to expose product operations as model-callable tools over stdio or Streamable HTTP with bearer-token auth, per-client rate limits, host allow-listing, structured call logging, and a swappable backend for secure, testable deployments.3MIT