Template-Based Development
We provide a basic MCP Server template, which includes a complete MCP Server project. You can modify it based on this project to develop your own MCP Server.
This article will introduce how to use this project code for local development, debugging, and deployment.
Click here to download the project code
Local Development and Debugging
Install Dependencies
npm i
Log in to the Command Line
The
@cloudbase/cli` requires login before use. Log in with your CloudBase account:
npm run login
Environment Variables
Rename .env.template
to .env.development
. This file defines the environment variables:
MCP_SSE_ROUTE=LOCAL
: Setting this enables the local SSE service, connecting MCP Inspector/MCP Host (e.g., Cursor) to the local MCP ServerSKIP_VERIFY_ACCESS=true
: Setting this will skip token verification. The original token verification will only allow calls from tokens with API Key and super administrator identities.CLOUDBASE_ENVIRONMENT=your-env-id
: In CloudBase hosted online environments, the context includes the CloudBase environment ID. During local development, we provide the environment ID by setting this environment variable. Set an environment ID under your currently logged-in account.
Setting the MCP_SSE_ROUTE
and SKIP_VERIFY_ACCESS
environment variables facilitates local debugging, but it is not recommended to configure them in the online production environment.
Start the Local MCP Server Service
npm run dev
Once started, the service will be available at http://localhost:3000/messages.
Modifying the code will trigger recompilation and restart the service.
Start Graphical Interface Debugging
Run MCP Inspector:
npx @cloudbase/mcp-inspector
Go to http://localhost:5173/ for debugging.
- On the left, select
POST
orSSE
type, and fill in theURL
ashttp://localhost:3000/messages
- Click
Connect
on the left - Under the
Tools
tab, clickList Tools
to display the tool list - Select any tool to invoke
Deploy to Cloud Hosting
Build
npm run build
Deploy
This MCP Server can be directly deployed to Cloud Hosting, but to use it in the Cloud Development Agent, you need to first create an MCP Server in the console and then overwrite its Cloud Hosting service.
First, go to the CloudBase Platform to create an MCP Server.
Once created, run the cli deployment command and fill in the corresponding MCP identifier.
npm run deploy
After deployment, you can read the following documentation to use the MCP Server: