You can develop custom MCP servers in TypeScript or Python and deploy them on Blaxel by integrating a few lines of the Blaxel SDK and leveraging our other developer tools (Blaxel CLI, GitHub action, etc.).

Quickstart

It is required to have npm (TypeScript) **or uv (Python) installed to use the following command.

You can quickly initialize a new MCP server from scratch by using CLI command bl create-mcp-server. This will create a pre-scaffolded local repo where your entire code can be added.

bl create-mcp-server my-mcp

You can test it by running the following command which launches both the server and a web application (MCP Inspector, managed by MCP) locally for testing the server’s capabilities during development.


pnpm inspect

The web application is accessible at: http://127.0.0.1:6274. Alternatively, you can just simply serve the server locally by running bl serve --hotreload.

Develop the MCP server logic (TypeScript)

If you open the src/server.ts file, you’ll see the complete server implementation. It follows the MCP server standard closely, with the only difference being our use of Blaxel transport for efficient platform serving.

The main component you’ll need to modify is the tool definition:

server.ts

import { BlaxelMcpServerTransport, logger } from "@blaxel/sdk";
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
import { z } from "zod";

const server = new McpServer({
  name: "mymcp",
  version: "1.0.0",
  description: ""
});

server.tool(
  "hello_world",
  "Say hello to a person",
  {
    firstname: z.string()
  },
  async ({firstname}) => {
    logger.info(`Hello world called`);
    return {
      content: [{ type: "text", text: `Hello ${firstname}` }]
    }
  }
);

function main() {
  let transport;
  if (process.env.BL_SERVER_PORT) {
    transport = new BlaxelMcpServerTransport();
  } else {
    transport = new StdioServerTransport();
  }
  server.connect(transport);
  logger.info("Server started");
}

main();

Remember that the name, description, and parameters are crucial—they help your agent understand how your tool functions.

Develop the MCP server logic (Python)

If you open the src/server.py file, you’ll see the complete server implementation. It follows the MCP server standard closely, with the only difference being our use of Blaxel transport for efficient platform serving.

The main component you’ll need to modify is the tool definition:

server.py

from blaxel import env
from blaxel.mcp.server import FastMCP

from typing import Annotated
from logging import getLogger

mcp = FastMCP("mcp-helloworld-python")
logger = getLogger(__name__)

@mcp.tool()
def hello_world(
    first_name: Annotated[
        str,
        "First name of the user",
    ],
) -> str:
    """Say hello to the user"""
    return f"Hello {first_name}!"

if not env["BL_DEBUG"]:
    mcp.run(transport="ws")

Deploy your MCP server

Just run bl deploy in the folder of your project, as explained in this guide.

bl deploy

Deploy your MCP server

Read our complete guide for deploying your custom MCP server on Blaxel.