Cover image
Try Now
2025-03-20

如何使用Elixir和SSE传输实现MCP服务器的示例

3 years

Works with Finder

1

Github Watches

1

Github Forks

3

Github Stars

Elixir MCP Server

An Elixir implementation of the Model Context Protocol (MCP) server using Elixir with Bandit and Plug.

The Model Context Protocol (MCP) is an open protocol that enables AI models to securely interact with local and remote resources through standardized server implementations. This project is a basic example of an MCP server using SSE (Server-Sent Events) as the transport protocol. It is based off the example at https://modelcontextprotocol.io/quickstart/server

Prerequisites

  • Elixir 1.18 or higher

  • Erlang/OTP 27 or higher

  • The weather API key can be set through the WEATHER_API_KEY environment variable. The default service is using the free tier of https://www.weatherapi.com/.

Getting Started

  1. Install dependencies:

    mix deps.get
    
  2. Start the server:

    WEATHER_API_KEY="1234567890abcdef" mix run --no-halt
    
    
    
  3. The server will be available at:

Available Tools

  • list_files: List files in a directory
  • echo: Echo a message back
  • get_weather: Get weather information

Testing with MCP Client

Install the NXP Inspector client and follow the instructions to connect to the server.

Make sure to use SSE (Server-Sent Events) as the transport protocol, then you should be able to list available tools and call them. Also to ping/keepalive the connection, you can use the ping tool.

Adding Custom Tools

To add custom tools, update the handle_initialize/2 function to include your tool definitions and implement corresponding handle_call_tool/3 clauses.

相关推荐

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

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

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

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

  • Khalid kalib
  • Write professional emails

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

  • Yasir Eryilmaz
  • AI scriptwriting assistant for short, engaging video content.

  • J. DE HARO OLLE
  • Especialista en juegos de palabras en varios idiomas.

  • Daren White
  • A supportive coach for mastering all Spanish tenses.

  • INFOLAB OPERATIONS 2
  • A medical specialist offering assistance grounded in clinical guidelines. Disclaimer: This is intended for research and is NOT safe for clinical use!

  • apappascs
  • 发现市场上最全面,最新的MCP服务器集合。该存储库充当集中式枢纽,提供了广泛的开源和专有MCP服务器目录,并提供功能,文档链接和贡献者。

  • ShrimpingIt
  • MCP系列GPIO Expander的基于Micropython I2C的操作,源自ADAFRUIT_MCP230XX

  • huahuayu
  • 统一的API网关,用于将多个Etherscan样区块链Explorer API与对AI助手的模型上下文协议(MCP)支持。

  • deemkeen
  • 用电源组合控制您的MBOT2:MQTT+MCP+LLM

  • zhaoyunxing92
  • MCP(消息连接器协议)服务

  • pontusab
  • 光标与风浪冲浪社区,查找规则和MCP

    Reviews

    4 (1)
    Avatar
    user_47Ln1x7I
    2025-04-15

    I am thoroughly impressed with CAD-MCP Server by daobataotie. This tool greatly simplifies managing CAD models with its robust control protocol. The performance and reliability are outstanding, making it an essential asset for any CAD enthusiast. Highly recommend checking it out at https://mcp.so/server/CAD-MCP/daobataotie!