Skip to main content
Glama

MyAIServ MCP Server

MCP 服务器 - 模型上下文协议 API

MCP Server 是基于 FastAPI 的模型上下文协议 (MCP) 实现,为 LLM 模型和应用程序之间的交互提供了标准化接口。

特点

  • 🚀 基于 FastAPI 和异步操作的高性能 API
  • 🔄**提供全面的 MCP 支持,**包括资源、工具、提示和采样
  • 📊 通过 Prometheus 和 Grafana 进行监控和指标
  • 🧩 通过简单的界面添加新工具的可扩展性
  • 📝 GraphQL API ,可灵活处理数据
  • 💬 WebSocket 支持实时交互
  • 🔍 通过与 Elasticsearch 集成进行语义搜索
  • 🗃️ 通过 Redis缓存以提高性能
  • 📦通过 Poetry管理依赖项以实现可靠的包管理

入门

安装

  1. 克隆存储库:
    git clone https://github.com/yourusername/myaiserv.git cd myaiserv
  2. 安装 Poetry(如果尚未安装):
    curl -sSL https://install.python-poetry.org | python3 -
  3. 通过 Poetry 安装依赖项:
    poetry install

启动服务器

poetry run uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload

或者通过 just 实用程序:

just run

启动后,API 可在以下网址访问: http://localhost:8000

API 文档

项目结构

myaiserv/ ├── app/ │ ├── core/ # Базовые компоненты MCP │ │ ├── base_mcp.py # Абстрактные классы MCP │ │ └── base_sampling.py # Базовые классы для сэмплирования │ ├── models/ # Pydantic модели │ │ ├── mcp.py # Модели данных MCP │ │ └── graphql.py # GraphQL схема │ ├── services/ # Бизнес-логика │ │ └── mcp_service.py # Сервис MCP │ ├── storage/ # Хранилище данных │ ├── tools/ # Инструменты MCP │ │ ├── example_tool.py # Примеры инструментов │ │ └── text_processor.py # Инструмент обработки текста │ ├── utils/ # Утилиты │ └── main.py # Точка входа FastAPI ├── app/tests/ # Тесты ├── docs/ # Документация │ └── MCP_API.md # Описание API ├── pyproject.toml # Конфигурация Poetry и инструментов └── .justfile # Задачи для утилиты just

可用工具

文件系统工具

支持读取、写入、删除和列出文件的文件系统工具。

curl -X POST "http://localhost:8000/tools/file_operations" \ -H "Content-Type: application/json" \ -d '{"operation": "list", "path": "."}'

天气工具

通过坐标获取天气数据的工具。

curl -X POST "http://localhost:8000/tools/weather" \ -H "Content-Type: application/json" \ -d '{"latitude": 37.7749, "longitude": -122.4194}'

文本分析工具

一种文本分析工具,包括情感检测和总结。

curl -X POST "http://localhost:8000/tools/text_analysis" \ -H "Content-Type: application/json" \ -d '{"text": "Example text for analysis", "analysis_type": "sentiment"}'

文本处理工具

文本处理工具,包括格式化、统计计算、实体提取。

curl -X POST "http://localhost:8000/tools/text_processor" \ -H "Content-Type: application/json" \ -d '{"operation": "statistics", "text": "Example text", "stat_options": ["chars", "words"]}'

图像处理工具

支持调整大小、裁剪和应用过滤器的图像处理工具。

curl -X POST "http://localhost:8000/tools/image_processing" \ -H "Content-Type: application/json" \ -d '{"operation": "resize", "image_data": "base64...", "params": {"width": 800, "height": 600}}'

WebSocket API

要连接到 WebSocket API:

const socket = new WebSocket("ws://localhost:8000/ws"); socket.onopen = () => { socket.send(JSON.stringify({ type: "initialize", id: "my-request-id" })); }; socket.onmessage = (event) => { const data = JSON.parse(event.data); console.log("Received:", data); };

GraphQL API

通过 GraphQL 进行查询的示例:

# Получение списка всех инструментов query { getTools { name description } } # Выполнение инструмента mutation { executeTool(input: { name: "text_processor", parameters: { operation: "statistics", text: "Example text for analysis" } }) { content { type text } is_error } }

运行测试

要运行测试,请使用 Poetry:

poetry run pytest

或者通过 just 实用程序:

just test

Docker

通过 Docker Compose 构建和运行

docker compose up -d

要启动单个服务:

docker compose up -d web redis elasticsearch

与 LLM 集成

MCP Server 提供了标准化接口,可与来自不同供应商的 LLM 模型集成:

import httpx async def query_mcp_with_llm(prompt: str): async with httpx.AsyncClient() as client: # Запрос к MCP для получения контекста и инструментов tools_response = await client.get("http://localhost:8000/tools") tools = tools_response.json()["tools"] # Отправка запроса к LLM с включением MCP контекста llm_response = await client.post( "https://api.example-llm.com/v1/chat", json={ "messages": [ {"role": "system", "content": "You have access to the following tools:"}, {"role": "user", "content": prompt} ], "tools": tools, "tool_choice": "auto" } ) return llm_response.json()

指标和监控

MCP 服务器通过/metrics端点提供 Prometheus 格式的指标。指标包括:

  • 每个工具的请求数量
  • 查询执行时间
  • 错误和异常

发展

格式化代码并使用 linters 检查:

just fmt just lint

执照

MIT 许可证

-
security - not tested
A
license - permissive license
-
quality - not tested

hybrid server

The server is able to function both locally and remotely, depending on the configuration or use case.

支持模型上下文协议 (MCP) 的高性能 FastAPI 服务器,可与大型语言模型无缝集成,具有 REST、GraphQL 和 WebSocket API,以及实时监控和向量搜索功能。

  1. 特点
    1. 入门
      1. 安装
      2. 启动服务器
      3. API 文档
    2. 项目结构
      1. 可用工具
        1. 文件系统工具
        2. 天气工具
        3. 文本分析工具
        4. 文本处理工具
        5. 图像处理工具
      2. WebSocket API
        1. GraphQL API
          1. 运行测试
            1. Docker
              1. 通过 Docker Compose 构建和运行
            2. 与 LLM 集成
              1. 指标和监控
                1. 发展
                  1. 执照

                    Related MCP Servers

                    • -
                      security
                      F
                      license
                      -
                      quality
                      A Model Context Protocol server that integrates with Cursor IDE, providing real-time communication, modern web dashboards, and extensible tools via SSE and WebSocket connections.
                      Last updated -
                      839
                      1
                      Python
                    • -
                      security
                      A
                      license
                      -
                      quality
                      A server that enables Large Language Models to discover and interact with REST APIs defined by OpenAPI specifications through the Model Context Protocol.
                      Last updated -
                      378
                      96
                      TypeScript
                      MIT License
                      • Apple
                    • -
                      security
                      F
                      license
                      -
                      quality
                      A Model Context Protocol server implementation that enables seamless integration with Claude and other MCP-compatible clients to access Prem AI's language models, RAG capabilities, and document management features.
                      Last updated -
                      JavaScript
                    • -
                      security
                      A
                      license
                      -
                      quality
                      A Model Context Protocol server that exposes over 200+ APIs from API.market as MCP resources, allowing large language models to discover and interact with various APIs through natural language commands.
                      Last updated -
                      111
                      2
                      TypeScript
                      MIT License
                      • Apple

                    View all related MCP servers

                    MCP directory API

                    We provide all the information about MCP servers via our MCP API.

                    curl -X GET 'https://glama.ai/api/mcp/v1/servers/eagurin/myaiserv'

                    If you have feedback or need assistance with the MCP directory API, please join our Discord server