✨ From vibe coding to vibe deployment. UBOS MCP turns ideas into infra with one message.

Learn more

Unleash the Power of Context: Building MCP Servers with UBOS for Enhanced AI Interactions

In the rapidly evolving landscape of Artificial Intelligence, the ability of AI models to access and utilize real-world data is paramount. This is where the Model Context Protocol (MCP) comes into play. MCP standardizes how applications provide context to Large Language Models (LLMs), enabling more informed and accurate AI responses. This document explores the creation and utilization of MCP servers, focusing on a practical example and highlighting the benefits of integrating them with platforms like UBOS.

Understanding MCP Servers: The Bridge Between AI and Reality

An MCP server acts as an intermediary, connecting AI models to external data sources and tools. Instead of relying solely on their internal knowledge base, AI models can query MCP servers to retrieve up-to-date information, execute specific tasks, and make decisions based on real-time context. This opens up a world of possibilities for AI applications, allowing them to:

  • Access Real-time Data: Retrieve the latest stock prices, weather forecasts, or news articles.
  • Interact with External APIs: Integrate with CRM systems, marketing automation platforms, or other business tools.
  • Perform Specific Actions: Trigger workflows, update databases, or send notifications.
  • Ground Responses in Facts: Avoid hallucinations and provide more accurate and reliable information.

A Practical Example: Building a Simple MCP Server

Let’s examine a simple example of an MCP server built with the mcp-framework. This server demonstrates the basic structure and functionality required to create a custom MCP server.

Project Structure

The project typically follows a structure like this:

my-mcp-server/ ├── src/ │ ├── tools/ # MCP Tools │ │ └── ExampleTool.ts │ └── index.ts # Server entry point ├── package.json └── tsconfig.json

  • src/tools/: This directory houses the individual tools that the MCP server exposes to AI models. Each tool represents a specific function or data source.
  • src/index.ts: This file serves as the entry point for the server, responsible for initializing the MCP framework and registering the available tools.
  • package.json: This file contains metadata about the project, including dependencies and build scripts.
  • tsconfig.json: This file configures the TypeScript compiler.

Adding Components: Building Custom Tools

The core of an MCP server lies in its tools. Each tool defines a specific action that an AI model can request. You can add new tools using a CLI (Command Line Interface), which simplifies the process of creating the necessary files and structures.

bash mcp add tool my-tool

This command generates a template for a new tool named my-tool. You can then customize this template to define the tool’s functionality.

Example tools you might create include:

  • data-processor: Processes and transforms data from various sources.
  • api-client: Interacts with external APIs to retrieve information or perform actions.
  • file-handler: Reads and writes data to files.

Tool Development: Defining Tool Logic

Each tool consists of three key components:

  1. Name: A unique identifier for the tool.
  2. Description: A human-readable description of the tool’s purpose.
  3. Schema: Defines the input parameters that the tool accepts.
  4. Execute function: Houses your tool logic.

typescript import { MCPTool } from “mcp-framework”; import { z } from “zod”;

interface MyToolInput { message: string; }

class MyTool extends MCPTool { name = “my_tool”; description = “Describes what your tool does”;

schema = { message: { type: z.string(), description: “Description of this input parameter”, }, };

async execute(input: MyToolInput) { // Your tool logic here return Processed: ${input.message}; } }

export default MyTool;

In this example, the MyTool tool accepts a single input parameter called message (string type), processes it, and returns a formatted output.

Publishing Your MCP Server: Sharing Your Creation

Once you’ve developed your MCP server, you can publish it to npm (Node Package Manager) to make it accessible to others. This involves:

  1. Updating package.json: Ensuring that the name, version, description, author, and other metadata are accurate and complete.
  2. Building and Testing Locally: Compiling the TypeScript code and testing the server to ensure it functions correctly.
  3. Logging into npm: Authenticating with your npm account.
  4. Publishing the Package: Uploading the package to the npm registry.

bash npm publish

After publishing, users can add it to their claude desktop client (read below) or run it with npx

Integrating with Claude Desktop: Empowering AI Interactions

Once you have a MCP Server, you can integrate it with AI platforms like Claude. This allows Claude to leverage the tools and data exposed by your server, enhancing its capabilities and enabling more complex interactions.

Local Development

For local development, you can configure Claude Desktop to point to your locally running MCP server by adding a configuration like this to your Claude Desktop config file:

MacOS: ~/Library/Application Support/Claude/claude_desktop_config.json Windows: %APPDATA%/Claude/claude_desktop_config.json

{ “mcpServers”: { “my-mcp-server”: { “command”: “node”, “args”:[“/absolute/path/to/my-mcp-server/dist/index.js”] } } }

After Publishing

After publishing your MCP server to npm, you can configure Claude Desktop to use the published version.

MacOS: ~/Library/Application Support/Claude/claude_desktop_config.json Windows: %APPDATA%/Claude/claude_desktop_config.json

{ “mcpServers”: { “my-mcp-server”: { “command”: “npx”, “args”: [“my-mcp-server”] } } }

UBOS: Streamlining AI Agent Development

While building individual MCP servers provides valuable context to AI models, managing and orchestrating multiple servers can become complex. This is where UBOS comes in. UBOS is a full-stack AI Agent Development Platform designed to simplify the creation, deployment, and management of AI agents.

Key Features of UBOS:

  • AI Agent Orchestration: UBOS allows you to easily orchestrate multiple AI agents, connecting them to your enterprise data and defining complex workflows.
  • Custom AI Agent Building: Build custom AI agents tailored to your specific needs, leveraging your own LLMs and datasets.
  • Multi-Agent Systems: Create sophisticated multi-agent systems that can collaborate to solve complex problems.
  • Seamless Integration with MCP Servers: UBOS seamlessly integrates with MCP servers, allowing you to easily incorporate external data and tools into your AI agents.

Use Cases of UBOS with MCP Servers:

  • Customer Service Automation: Connect AI agents to CRM systems via MCP servers to provide personalized customer support.
  • Sales Intelligence: Use MCP servers to access real-time market data and provide sales agents with actionable insights.
  • Financial Analysis: Integrate AI agents with financial data providers via MCP servers to automate financial analysis and reporting.
  • Supply Chain Optimization: Connect AI agents to supply chain management systems via MCP servers to optimize logistics and inventory management.

Conclusion: The Future of AI with Context

MCP servers are essential for enabling AI models to interact with the real world and provide more accurate and relevant information. Platforms like UBOS further enhance the power of MCP servers by providing a comprehensive environment for building, deploying, and managing AI agents. As AI continues to evolve, the ability to leverage context will become increasingly important, and MCP servers will play a central role in shaping the future of AI applications.

By using UBOS, organizations can drastically simplify the integration of MCP servers into their AI strategies, unlocking the full potential of contextual AI and driving innovation across various industries. The combination of UBOS and MCP empowers businesses to build smarter, more responsive, and ultimately more valuable AI solutions.

Featured Templates

View More
Customer service
Multi-language AI Translator
136 921
Customer service
Service ERP
126 1188
AI Assistants
Talk with Claude 3
159 1523
AI Engineering
Python Bug Fixer
119 1433

Start your free trial

Build your solution today. No credit card required.

Sign In

Register

Reset Password

Please enter your username or email address, you will receive a link to create a new password via email.