MCP cover image
See in Github
2025-01-13

Mirror ofhttps: //github.com/agentico-dev/mcp-server

0

Github Watches

1

Github Forks

0

Github Stars

mcp-server NPM Version

MCP Server is a simple server that implements the Model Context Protocol (MCP) to provide a simpler API to interact with the Model Context Protocol.

Why Use This Server?

In "La Rebelion" we are working on a set of tools and services to simplify processes and workflows for a better and more efficient developer experience. This server is part of a set of tools.

MCP is amazing, but it can be a bit confusing to get started. We have create a facade to simplify the process of creating a server that implements the Model Context Protocol. The pattern is simple, you just need to create the tools with your own logic, register the tools and start the server.

Steps to Create a New Server

In the future we will provide a CLI to create a new server similar to MCP create server, but for now you can follow the steps below based on the official documentation to create a server.

mkdir -p my-server/src
cd my-server/
yarn init -y
yarn add @modelcontextprotocol/sdk zod zod-to-json-schema
yarn add -D @types/node typescript
# Here lies the magic
yarn add @agentico/mcp-server

You need to update the package.json file and create a tsconfig.json file.

Getting Started

Implement your tools with your custom logic, and register them in the MCPServer. Here is an example of a simple echo tool:

import { Tool, ToolSchema } from "@agentico/mcp-server";

export class EchoTool extends Tool {
  toolSchema: ToolSchema = { 
    name: "echo",
    description: "Echoes the input message",
    schema: { // the schema for the parameters needed by the tool
      type: "object",
      properties: {
        message: { type: "string" },
      },
      required: ["message"],
    },
  };

  /**
   * Your logic here, implement the execute method to define the tool behavior
   * @param input The input message - use the schema to define the input type
   * @returns In the example, we are echoing the message
   */
  async execute(input: any): Promise<any> {
    // This is a simple echo tool demo, nothing fancy, just echoing the message
    return Promise.resolve({
      content: [
        {
          type: "text",
          text: `${input.message}` 
        }
      ]
      });
  }
}

Create an index.ts file with the following content:

#!/usr/bin/env node
import { MCPServer } from '@agentico/mcp-server'
import { EchoTool } from "./tools/EchoTool.js";

const myServer = new MCPServer('My MCP Server', '1.0.0');

async function main() {
  // Register tools
  myServer.registerTool("echo", EchoTool);
  await myServer.run();
}

main().catch((error) => {
  console.error("Server error:", error);
  process.exit(1);
});

That's it! You have created a simple server that implements the Model Context Protocol. Test it with Claude Desktop or any other client that supports MCP.

Build the project with the following command:

yarn build

You can start the server, but has no logic yet, you can test it with the following command:

yarn start
# or
node build/index.js

That's it, start creating your own tools and services to simplify your workflows and processes.

Go Rebels! ✊🏻

UML Diagram

UML Diagram

  • MCPServer: Registers the tools that will be used by the server.
  • Tool: Base class for all tools, containing common properties and methods. execute is the method that will be called when the tool is invoked, implement your logic here.
  • EchoTool: Specific implementation of a tool, extending the Tool class and defining its own schema and initialization logic.
  • EchoSchema: Defines the structure of the input for the EchoTool.
  • EchoInput: Type definition for the input based on the schema.

This pattern allows for a flexible and extensible way to manage and implement tools using the MCPServer and Tool classes.

Support Us

If you find this useful, please consider supporting us by starring this repository, by contributing to the project or by becoming a sponsor.

You can find more information on how to support us at La Rebelion GitHub Sponsors. Also buying us a coffee, PayPal are great ways to support us or purchasing "La Rebelion" merch.

License

This project is licensed under the MIT License - see the LICENSE file for details.

相关推荐

  • NiKole Maxwell
  • I craft unique cereal names, stories, and ridiculously cute Cereal Baby images.

  • Bora Yalcin
  • Evaluator for marketplace product descriptions, checks for relevancy and keyword stuffing.

  • https://jgadvisorycpa.com
  • This GPT assists in finding a top-rated business CPA - local or virtual. We account for their qualifications, experience, testimonials and reviews. Business operators provide a short description of your business, services wanted, and city or state.

  • https://suefel.com
  • Latest advice and best practices for custom GPT development.

  • Yusuf Emre Yeşilyurt
  • I find academic articles and books for research and literature reviews.

  • https://maiplestudio.com
  • Find Exhibitors, Speakers and more

  • Carlos Ferrin
  • Encuentra películas y series en plataformas de streaming.

  • Joshua Armstrong
  • Confidential guide on numerology and astrology, based of GG33 Public information

  • Emmet Halm
  • Converts Figma frames into front-end code for various mobile frameworks.

  • Elijah Ng Shi Yi
  • Advanced software engineer GPT that excels through nailing the basics.

  • lumpenspace
  • Take an adjectivised noun, and create images making it progressively more adjective!

  • apappascs
  • Entdecken Sie die umfassendste und aktuellste Sammlung von MCP-Servern auf dem Markt. Dieses Repository dient als zentraler Hub und bietet einen umfangreichen Katalog von Open-Source- und Proprietary MCP-Servern mit Funktionen, Dokumentationslinks und Mitwirkenden.

  • OffchainLabs
  • GO -Umsetzung des Ethereum -Beweises des Anteils

  • modelcontextprotocol
  • Modellkontext -Protokollserver

  • huahuayu
  • Ein einheitliches API-Gateway zur Integration mehrerer Ethercan-ähnlicher Blockchain-Explorer-APIs mit Modellkontextprotokoll (MCP) für AI-Assistenten.

  • Mintplex-Labs
  • Die All-in-One-Desktop & Docker-AI-Anwendung mit integriertem Lappen, AI-Agenten, No-Code-Agent Builder, MCP-Kompatibilität und vielem mehr.

    Reviews

    3 (1)
    Avatar
    user_UhI2SLGw
    2025-04-17

    As a dedicated user of the agentico-dev_mcp-server by MCP-Mirror, I'm thoroughly impressed with its functionality and performance. The server seamlessly integrates into my development workflow, providing a robust and reliable backend solution. The comprehensive documentation and active support from the community make it an indispensable tool for any developer. Highly recommended!