Deploy serverless MCP examples easily with Netlify functions and deployment tools
The MCP Example Server acts as an entry point to demonstrate how one can create and deploy a Model Context Protocol (MCP) server integrated with Netlify Functions. This example serves as a foundational template, which developers can adapt or extend to suit more complex integrations within their AI applications.
This server leverages the simplicity of Express.js and Netlify’s serverless functions to provide a flexible and scalable solution for running AI applications like Claude Desktop, Continue, and Cursor. The core feature is its seamless integration with Netlify’s Function framework, enabling real-time API calls from client applications without the need for a traditional backend.
The example showcases how any MCP-compatible client can interact directly with the server, allowing for various use cases such as authentication, configuration, and data retrieval. The simplicity of setting up these interactions makes it easy to integrate this server into broader AI workflows.
The server’s architecture is designed to adhere strictly to MCP protocol guidelines. This ensures that any deployed instance can seamlessly communicate with an MCP client, providing a consistent and reliable experience across different applications.
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
The compatibility matrix below outlines the support for different MCP clients integrated with this server.
MCP Client | Resources | Tools | Prompts | Status |
---|---|---|---|---|
Claude Desktop | ✅ | ✅ | ✅ | Full Support |
Continue | ✅ | ✅ | ✅ | Full Support |
Cursor | ❌ | ✅ | ❌ | Tools Only |
To set up and run this example server locally, follow these steps:
# 1. Clone the examples repository to your local development environment
git clone [email protected]:netlify/examples
# 2. Move into the project directory for this example
cd examples/mcp/express-mcp
# 3. Install Netlify CLI globally to serve your site locally
npm i -g netlify-cli
# 4. Use Netlify Dev to run and test your local serverless functions
netlify dev
# 5. Access the inspector or client you desire while serving locally
npx @modelcontextprotocol/inspector npx mcp-remote@next http://localhost:8888/mcp
This server facilitates a range of use cases that enhance AI application capabilities. Below are two practical examples:
Use the MCP client to fetch and manage resources dynamically. This could be any resource such as database entries, configurations, or external APIs.
curl -X GET "http://localhost:8888/mcp/resources" \
-H "Content-Type: application/json" \
-d '{"tool": "fetchDatabaseEntries"}'
Leverage the server to generate prompts based on data retrieved from various tools. This can be particularly useful in generating context for user interactions.
curl -X POST "http://localhost:8888/mcp/prompt" \
-H "Content-Type: application/json" \
-d '{"context": "user input", "tool": "naturalLanguageProcessing"}'
The example includes a setup for netlify functions, which are triggered by client requests. The provided configuration allows any MCP-compatible client to interact directly with the server.
{
"mcpServers": {
"example-server": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-express"],
"env": {
"API_KEY": "your-api-key"
}
}
}
}
While this example focuses on basic functionality, it serves as a robust starting point for further optimization. The performance of the server can be enhanced by tweaking Netlify’s Function settings and optimizing code efficiency.
To ensure secure and efficient operation, users should set up environment variables and adjust server-side configurations as needed. Additional security features can be implemented through middleware or external security services.
const express = require('express');
const functionHandler = require('@netlify/functions/express-mcp');
const app = express();
// Middleware to handle CORS and ensure secure access
app.use((req, res, next) => {
res.header("Access-Control-Allow-Origin", "*");
res.header(
"Access-Control-Allow-Headers",
"Origin, X-Requested-With, Content-Type, Accept"
);
next();
});
// Define routes using Express
app.get('/mcp', functionHandler);
// Start the server
const PORT = process.env.PORT || 8080;
app.listen(PORT, () => {
console.log(`Server is running on port ${PORT}`);
});
Why use Netlify for this MCP server?
Can I integrate more tools with this example server?
Does this work with older versions of MCP clients?
What are some best practices in setting up MCP servers?
How can I debug issues with the MCP server?
Contributions are welcome! If you’d like to contribute, please follow these guidelines:
Explore the broader MCP ecosystem:
By following these guidelines, developers can build on this basic example server to create sophisticated MCP integrations that enhance AI application functionality.
Next-generation MCP server enhances documentation analysis with AI-powered neural processing and multi-language support
Learn to connect to MCP servers over HTTP with Python SDK using SSE for efficient protocol communication
Python MCP client for testing servers avoid message limits and customize with API key
Learn how to use MCProto Ruby gem to create and chain MCP servers for custom solutions
Analyze search intent with MCP API for SEO insights and keyword categorization
AI Vision MCP Server offers AI-powered visual analysis, screenshots, and report generation for MCP-compatible AI assistants