Skip to main content

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 Server
  • SKIP_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.
tip

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.

  1. On the left, select POST or SSE type, and fill in the URL as http://localhost:3000/messages
  2. Click Connect on the left
  3. Under the Tools tab, click List Tools to display the tool list
  4. 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: