DEV Community

Cover image for ๐Ÿš€ Build a Remote MCP Server That Connects to Any MCP Client (Claude, VSCode & More)

๐Ÿš€ Build a Remote MCP Server That Connects to Any MCP Client (Claude, VSCode & More)

The Model Context Protocol (MCP) is quickly becoming the new universal standard for connecting AI assistants with real-world tools. Imagine giving Claude, VSCode, or any MCP-compatible client the power to interact with your APIs, databases, scripts, or cloud resourcesโ€”securely and consistently.

In this guide, youโ€™ll learn:

โœจ What an MCP Server is

โš™๏ธ How to build one

๐Ÿ”Œ How MCP Clients connect

๐Ÿงฐ Deployment options (Cloudflare, Cloud Run, custom hosting)

๐Ÿ’ป Example code + a public repository template


๐Ÿง  What Is an MCP Server?

An MCP Server is a backend service that exposes tools, resources, prompts, or custom logic to AI clients through a standardized protocol.

Think of it as:

๐Ÿ› ๏ธ Your own plugin system for AI models.

If you can code it, an LLM can use it.

With an MCP Server, you can expose:

  • ๐Ÿ“ก API requests
  • ๐Ÿ—‚๏ธ Database queries
  • ๐Ÿ’พ File operations
  • ๐Ÿ” Secure internal tools
  • ๐Ÿงฎ Business logic
  • ๐Ÿ› ๏ธ Any custom code/functionality

And any MCP Client can use it immediately:

  • Claude Desktop
  • Claude on Web (with model contexts)
  • VSCode MCP Extension
  • Cursor (partial)
  • Custom terminals or agents

๐Ÿ”Œ How MCP Servers Connect to Clients

MCP uses a clean JSON-based message protocol on top of common transports:

  • ๐Ÿ”— WebSockets
  • ๐Ÿงต STDIO
  • ๐ŸŒ HTTP Streaming
  • โ˜๏ธ Cloudflare Workers Channels
  • ๐Ÿš€ Google Cloud Run HTTP endpoints

Clients send messages like:

  • initialize
  • list_tools
  • call_tool
  • read_resource

And the server responds with structured results.

This design makes MCP servers portable, cloud-ready, and language-agnostic ๐Ÿ’ก.


๐Ÿ› ๏ธ Minimal MCP Server Example (TypeScript)

Below is a simple starter server that exposes one tool called hello_world:

import { Server, Tool } from "@modelcontextprotocol/sdk/server";

const server = new Server({
  name: "example-mcp-server",
  version: "1.0.0",
});

server.tool(
  new Tool("hello_world", {
    description: "Returns a greeting message.",
    inputSchema: {
      type: "object",
      properties: {
        name: { type: "string" },
      },
      required: ["name"],
    },
    async handler({ name }) {
      return { message: `Hello, ${name}!` };
    },
  })
);

server.listen();
Enter fullscreen mode Exit fullscreen mode

This simple server:

โœ”๏ธ Registers one tool
โœ”๏ธ Accepts a name argument
โœ”๏ธ Returns a message response
โœ”๏ธ Works with any MCP client


๐Ÿงฉ Connecting Your MCP Server to Claude Desktop

{
  "servers": [
    {
      "name": "My MCP Server",
      "type": "websocket",
      "url": "wss://your-public-server.com"
    }
  ]
}
Enter fullscreen mode Exit fullscreen mode

๐Ÿงฉ Connecting to VSCode (MCP Extension)

{
  "mcpServers": {
    "myServer": {
      "command": "node",
      "args": ["./dist/server.js"]
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

Your tools will show up in the MCP panel inside VSCode ๐Ÿ“Ž.

โ˜๏ธ Deployment Options

๐ŸŒฉ๏ธ 1. Cloudflare Workers

Perfect for serverless, instant deployments:

Steps:

  1. Clone example project
  2. Configure wrangler.toml
  3. Run wrangler deploy
  4. Fast, free-tier friendly, globally distributed.

๐Ÿš€ 2. Google Cloud Run

Google published a full tutorial + sample repo:

Cloud Run gives you:

  • Auto-scaling
  • Pay-per-request
  • HTTPS by default

๐Ÿงฑ 3. Custom Hosting

Run it anywhere:

  • EC2
  • Docker
  • Kubernetes
  • PM2 on a VPS
  • Local dev machine

MCP only requires a transport channel (WebSocket or STDIO).

๐ŸŽฏ Why Build Your Own MCP Server?

๐Ÿ’ผ Enterprise automation
๐Ÿ›ก๏ธ Secure tool access
๐Ÿ”Œ Standardized integrations
๐Ÿงฉ One tool layer usable across all AI apps
โšก Faster development for agentic workflows
๐ŸŒ Cloud portability and vendor independence

If you're building AI-powered tools, MCP Servers are the future.

๐Ÿ“ฆ Example Public Repository

Here is a clean, minimal, ready-to-use MCP Server starter repo:

๐Ÿ‘‰ GitHub Example (Community Template):

This repository includes:

  • TypeScript source code
  • Example tools
  • Transport implementation
  • Scripts for running the server
  • Instructions for connecting to Claude and VSCode

You can fork it and start adding your own tools immediately.

๐ŸŽ‰ Final Thoughts

MCP is transforming how AI apps interact with the real world.
By building your own MCP Server, you unlock:

โœจ Secure, structured, AI-driven automation
โœจ Native integration with Claude & IDEs
โœจ Cloud-ready extensibility
โœจ A reusable tool layer for any AI agent

If you want, I can also:

๐Ÿ”ง Build a full boilerplate MCP server repo for you
๐Ÿ“˜ Write a step-by-step Cloudflare or Cloud Run deployment guide
๐Ÿงฉ Generate architecture diagrams
๐ŸŽจ Create a cover image for your dev.to article

Just tell me!

Top comments (0)