DEV Community

Cover image for Building a Remote MCP Server on Contextum (Without Auth)
Contextum
Contextum

Posted on

Building a Remote MCP Server on Contextum (Without Auth)

app.contextum.orgAs AI and Web3 ecosystems continue to evolve, developers face the challenge of building scalable, flexible, and secure infrastructure for their applications. One such solution is deploying Model Context Protocol (MCP) servers that can manage context data for AI models or agents. Contextum offers a simple, serverless way to deploy remote MCP servers without the hassle of authentication, so you can focus on building and testing your AI and Web3 applications quickly.

This article will guide you through the process of setting up a remote MCP server on Contextum, why it’s a great tool for rapid development, and how to easily connect it to the Contextum Playground or local clients.

Why You Should Build a Remote MCP Server on Contextum

When building AI systems, managing context data and enabling easy interaction with various tools is crucial. However, setting up traditional servers or managing complex authentication mechanisms often adds unnecessary overhead. Here’s why using Contextum for deploying a remote MCP server without authentication is a compelling choice:

  • Zero Authentication Overhead: Authentication systems can significantly complicate development workflows, especially in early stages or prototypes. Contextum removes this complexity by allowing you to deploy an MCP server that doesn’t require managing user identities or tokens.

  • Frictionless Integration: With Contextum, you can deploy your MCP server and connect it to the Contextum Playground or local clients in minutes, giving you a quick feedback loop for testing and iterating on your AI models.

  • Highly Extendable: Contextum is designed to be flexible. You can easily add custom tools to the MCP server, integrate your own models, and extend the server's functionality as your project grows.

  • Web3 Compatibility: Contextum is ideal for decentralized AI projects. The serverless nature of the platform combined with decentralized tools makes it perfect for Web3 applications that need to manage AI context data in a distributed, scalable manner.

Now, let’s dive into how to set up and deploy a remote MCP server on Contextum.

Step-by-Step Guide to Building Your Remote MCP Server on Contextum

Step 1: Initialize Your Project

Start by creating a new Contextum project that includes a template for a remote MCP server without authentication. This template comes pre-configured with basic tools that you can modify and extend based on your needs.

Run the following command to create a new Contextum project:

npm create contextum@latest -- my-mcp-server --template=contextum/ai/demos/remote-mcp-authless
Enter fullscreen mode Exit fullscreen mode

This command will scaffold a new project for you in the my-mcp-server directory. Once the project is created, navigate into the project directory and install the dependencies:

cd my-mcp-server
npm install
Enter fullscreen mode Exit fullscreen mode

Step 2: Customize Your MCP Server

In the src/index.ts file, you can define and customize the tools that your server will provide. Here is an example of adding two tools: a simple calculator and a multiplier.

import { MCPServer } from "contextum-server";

class MyMCPServer extends MCPServer {
  init() {
    // Tool to add two numbers
    this.server.tool("calculator", (input) => {
      return {
        result: input.number1 + input.number2
      };
    });

    // Tool to multiply two numbers
    this.server.tool("multiplier", (input) => {
      return {
        result: input.number1 * input.number2
      };
    });

    // Tool to divide two numbers
    this.server.tool("divider", (input) => {
      if (input.number2 === 0) {
        return { error: "Cannot divide by zero!" };
      }
      return { result: input.number1 / input.number2 };
    });
  }
}

export default new MyMCPServer();
Enter fullscreen mode Exit fullscreen mode

In this example, we define three tools:

  • calculator: Adds number1 and number2 from the input.
  • multiplier: Multiplies number1 and number2.
  • divider: Divides number1 by number2, with an error check for division by zero.

These tools are defined using this.server.tool(...) and can be accessed via the MCP server once it’s deployed.

Step 3: Deploy Your MCP Server to Contextum

After configuring your server, deploy it to Contextum. The deployment process is straightforward, and the Contextum CLI handles all the infrastructure management for you.

To deploy your server, simply run:

npm run deploy
Enter fullscreen mode Exit fullscreen mode

After deployment, your server will be available at a URL like:

https://<your-project-name>.app.contextum.org/sse
Enter fullscreen mode Exit fullscreen mode

This is the endpoint you’ll use to interact with your server, either from the Contextum Playground or local clients.

Step 4: Connect Your MCP Server to the Contextum Playground

The Contextum Playground is an interactive, web-based environment for testing and experimenting with your MCP server. To connect to your deployed server, follow these steps:

  1. Visit the Contextum AI Playground at https://playground.contextum.org/.
  2. Enter the URL of your deployed server: https://<your-project-name>.app.contextum.org/sse.

Once connected, you can interact with the tools you’ve defined (like calculator, multiplier, and divider) directly in the Playground. This makes it easy to test the server's behavior in real time.

Step 5: Connect Your MCP Server to Local Clients

You can also connect your remote MCP server to local clients using the mcp-remote proxy. This allows you to send requests to your remote server from tools like Claude Desktop.

To connect Claude Desktop to your MCP server, follow these steps:

  1. Open Claude Desktop.
  2. Go to Settings > Developer > Edit Config.
  3. Add the following configuration for your MCP server:
{
  "mcpServers": {
    "calculator": {
      "command": "npx",
      "args": [
        "mcp-remote",
        "https://<your-project-name>.app.contextum.org/sse"
      ]
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

This configuration tells Claude Desktop to route its MCP requests through your remote server. Once you restart the application, you should see your defined tools available for use.

Advantages of Using Contextum for Remote MCP Servers

  • No Authentication Hassles: Traditional authentication systems can be time-consuming to set up and manage. By using Contextum’s authentication-free server, you can bypass all the extra work and focus on building your application.

  • Rapid Deployment: With Contextum, deploying your server is as simple as running a single command. You don’t have to manage infrastructure, allowing you to focus on the tools and functionality you want to offer.

  • Seamless Integration: Whether you’re using the Contextum Playground for interactive testing or connecting to local tools like Claude Desktop, Contextum makes integration smooth and effortless.

  • Extendable and Scalable: Add any custom tools you need to extend the functionality of your MCP server. Whether it’s building new AI models or integrating third-party tools, Contextum supports all your needs as your project grows.

  • Ideal for Web3: The serverless, decentralized nature of Contextum makes it a perfect fit for Web3 applications where decentralized context management is a key component.


Official Links for Contextum:

This setup empowers developers to build and deploy remote MCP servers quickly, test them interactively, and integrate them with various AI tools without having to deal with complex authentication systems or infrastructure management.


This version should be ready for dev.to with added Contextum links for further engagement!

Top comments (0)