As the Large Language Model (LLM) ecosystem is rapidly evolving, Model Context Protocol (MCP), as a standardized protocol that connects AI capabilities with the real world, is gradually becoming the de facto standard for intelligent agent development. The protocol defines three core capabilities: Resources (static resources), Prompts (prompt templates), and Tools (executable tools), allowing developers to expand LLM's interactive capabilities such as file system access, API integration, and even IoT control in a modular way.
However, the current development and deployment of MCP Server still has significant pain points: developers need to manually configure Python/TypeScript SDK, handle dependency conflicts, and ultimately solve the IaC deployment problem in the cloud by themselves. This fragmented experience makes it too expensive to build an MCP Server from scratch. With the Serverless Devs CLI tool, developers can pull up the MCP Server project with one click, and deploy it to the cloud with one click after development is completed, significantly shortening the development process and improving the development efficiency of the MCP Server.
This article will show you how to use the Serverless Devs CLI tool to develop and deploy a native SSE sample MCP Server to Alibaba Cloud Function Compute (FC) with one click . It also provides a client with built-in LLM to test the deployed MCP Server.
What are Serverless Devs?
Cloud Native
Serverless Devs [1] is an open source Serverless developer platform dedicated to providing developers with a powerful tool chain system. Through this platform, developers can experience multi-cloud Serverless products with one click and deploy Serverless projects at high speed. Serverless Devs was officially open sourced on October 23, 2020, and entered the CNCF sandbox in 2022, becoming the first selected Serverless tool project. The project has currently served thousands of developers and enterprise users.
Serverless Devs includes CLI tools, Registry (various popular AI application templates, practical AI tools, and AI workflows), CICD tools, and works closely with Function Compute FC and FunctionAI development platforms to provide developers with more convenient Serverless+AI services.
Developing MCP Server from scratch
Cloud Native
Initialize MCP Server locally
To initialize the MCP Server project locally, you need to use the Serverless Devs tool. You can follow this document [2] to install it. After installation and configuration, initialize a Hello World MCP Server project using the following command:
s init start-mcp-nodejs-hello-world
Follow the prompts to fill in the region, function name and configured access to complete the project initialization:
The directory structure of the project is as follows:
.├── build.yaml # Build configuration├── code # Project code directory│ ├── check_node_version.mjs # Pre-deployment check script│ ├── package-lock.json │ ├── package.json │ ├── src│ │ └── index.ts # Project source code│ ├── tsconfig.json│ └── webpack.config.js├── readme.md└── s.yaml # Deployment YAML
Developing MCP Server
In the project root directory code
The folder is the directory of the project code. During deployment, only the contents in this folder will be deployed to the Function Compute FC. src/index.ts
file, you can see that the CLI has already written a simple, deployable Hello World MCP Server for you:
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" ;
import { z } from "zod" ;
import express from "express" ;
import { SSEServerTransport } from "@modelcontextprotocol/sdk/server/sse.js" ;
// Create a map to store the transport for each session
const sessionTransport : Map < string , SSEServerTransport > = new Map ();
// Create a new server instance every time a new connection is made to ensure concurrency
const createServer = () => {
// Create server instance
const server = new McpServer ({
name : "my-mcp-server" ,
version : "1.0.0" ,
});
// Implement your tools here
server.tool (
"hello_world" ,
"Return string 'hello world!'" ,
{
// Define input parameters using zod. example:
// prefix: z.string().describe('prefix').optional(),
},
async () => {
console .log ( " Hello World tool called" );
return {
content : [{
type : "text" ,
text : 'hello world!' ,
}]
}
},
);
return server;
}
const app = express ();
app.get ( "/sse" , async (req, res) => {
console .log ( " SSE connection opened" );
console . log ( "Request Headers:" , req?. headers ); // Output specific properties on demand
console . log ( "Request Query:" , req?. query );
const server = createServer ();
server. server . onclose = async () => {
await server.close () ;
sessionTransport.delete ( transport.sessionId ) ;
};
const transport = new SSEServerTransport ( "/messages" , res);
sessionTransport.set ( transport.sessionId , transport) ;
await server. server . connect (transport);
return ;
});
app. post ( "/messages" , async (req, res) => {
const sessionId = req. query . sessionId as string ;
if (!sessionId) {
throw new Error ( "sessionId query parameter is required" );
}
const transport = sessionTransport.get (sessionId) ;
if (transport) {
console .log ( "SSE message received" ) ;
console . log ( "Request Headers:" , req?. headers ); // Output specific properties on demand
console . log ( "Request Query:" , req?. query );
console . log ( "Request Body:" , req?. body );
await transport. handlePostMessage (req, res);
}
return ;
});
app.listen ( 8080 , ( ) => {
console .log ( ' MCP Server running on port 8080' );
});
This Server contains a name hello_world
The tool will only return a string 'hello world!'
, and does not require any input parameters. You can refer to the current code implementation to modify the tool yourself, and the CLI has already configured it for you package.json
You can develop any Node.js
Develop this Server in a project-based way.
Deploy MCP Server to Function Compute FC
Cloud Native
After completing the development of the server, you can use the Serverless Devs CLI tool to deploy your MCP server to Function Compute with one click. s.yaml
To deploy code, it needs to contain all the information required for deployment, including instance specifications, code directories, trigger configurations, etc. The CLI has already been written for you, so you don't need to worry about these.
Before deployment, the code needs to be packaged. Here we use webpack
To package, the configuration has been written for you, so you only need to code
Execute the following command in the directory:
Note: The local node version must be 20 or above.
npm install # If you have not executed npm run build before
like code
The directory appears dist
The folder contains the following files, indicating that the build is successful:
At this point, you are ready to deploy this server to Function Compute! Go back to the project root directory and execute the following command:
s deploy -y
If you see the following information, the deployment is successful. After the deployment is successful, Serverless Devs will print the configuration information of the successfully deployed function:
✔ [start-mcp-nodejs-hello-world] completed (5.9s)
? Result for [deploy] of [start-mcp-server-nodejs]
====================
region: xxxxx
......Configuration Information
in,functionName
This is the name of the deployed function. You can log in to the Alibaba Cloud Function Compute Console [3] to view it. You can also find it in the configuration information. system_url
field, this is the URL of your MCP Server, which can be used for testing and integration into your own system.
Testing MCP Server
Cloud Native
You can start an official inspector locally [4] to test the deployed MCP. Just execute:
npx @modelcontextprotocol/inspector node build/index.js
Alternatively, you can also start an inspector that we modified based on the official project and has LLM built in:
npx @serverless-devs/inspector node build/index.js
Transport Type
choose SSE
, copy the previously deployed system_url
, add at the end /sse
, then paste it into URL
Input box. Click Connect
, then cut to Tools
, click List Tools
, you can see the tool information of the deployed Server and debug it.
If you are using our inspector with large models, you can also switch to LLM
, select the large model, fill in your API Key, and test the effect of the large model using your tool:
You need to click List Tools first, otherwise the tools cannot be used in large models
Three ways to access the client
Cloud Native
Method 1: Official Client
All MCP servers deployed to Function Compute FC follow the SSE protocol. For official clients that already support SSE (such as Cursor), the access configuration is as follows:
{ "mcpServers": { "server-name": { "url": "<deployed system_url>/sse", "env": { // If any "key": "value" } } }}
For clients that do not yet support SSE, you can refer to some open source community proxy solutions, such as:
mcp-pro xy 【5】
supergateway 【6】
Method 2: Other local clients
For unofficial clients, accessing the MCP Server requires using the official SDK. For specific development methods, please refer to the official documentation [7] . An example Node Client is as follows:
import { Client } from "@modelcontextprotocol/sdk/client/index.js" ;
import { SSEClientTransport } from "@modelcontextprotocol/sdk/client/sse.js" ;
const client = new Client ({
name : "example-client" ,
version : "1.0.0"
}, {
capabilities : {}
});
const transport = new SSEClientTransport (
new URL ( "<deployed system_url>/sse" )
);
await client.connect (transport) ;
Method 3: Deploy a Client on FC
If you need a remote client, you can also deploy the inspector to Function Compute in the Function Compute FC Application Center. You can deploy it with one click through this link [8] . After the deployment is complete, click the domain name to enter the inspector interface.
Conclusion
Cloud Native
At this point, you have successfully initialized, developed, and deployed your own SSE MCP Server! In addition to the Node-based MCP Server Hello World project demonstrated in the article, Serverless Devs also provides Hello World projects based on Python and Java, as well as a large number of open source servers that can be deployed with one click, including Amap, Baidu Maps, Github, etc. For details, please see this code repository [9] .