JM

javierustk/mormot-mcp-server

开发工具

本页由 AI 翻译,技术细节请以原文为准。 查看原文

22 stars 4 forks 质量 72 趋势 24MIT

Delphi 在 mORMot2 上的完整 MCP 2025-06-18 规范实现

概览

采用mORMot2框架实现高性能模型上下文协议(MCP)服务器。 (无状态的每请求模型,服务器/发现,订阅/监听),并完全向后兼容基于初始化的客户端(2024-11-05 至 2025-11-25),并通过 SSE 实现双向通知。 - - 没有外部依赖,仅限于 mORMot2 - - 支持带有 SSE 的 stdio 和 HTTP - - 使用 TDocVariant 提供完整协议支持 - - 通过自定义工具、资源和提示轻松扩展 - - 使用 Delphi 和 Free Pascal 编译 - - 注册带有 JSON Schema 验证和 listChanged 通知的自定义工具 - - 通过基于 URI 的访问列表、读取、模板和订阅 - - 多种内容类型(文本、图片、音频、资源)进行列表和获取 - - setLevel 方法与 RFC 5424 日志层级 - - 提示和资源的参数自动补全 - - JSON-RPC 换行分隔,日志转为 stderr - - 支持 Server-Sent Events(SSE)、CORS 和 TLS 的 REST API—— 加密会话 ID......

概述(AI 翻译)

🇪🇸 Leer en español

采用mORMot2框架实现高性能模型上下文协议(MCP)服务器。

实现MCP规范2026-07-28(无状态每请求模型,server/discover、subscriptions/listen),并完全向后兼容基于初始化的客户端(2024-11-05至2025-11-25)并通过SSE实现双向通知。

特色

核心

  • 纯mORMot2实现 - 无外部依赖,仅限于mORMot2
  • 双传输支持 - 带SSE的stdio和HTTP
  • JSON-RPC 2.0 - 使用TDocVariant 实现完整协议支持
  • 模块化架构 - 通过自定义工具、资源和提示词轻松扩展
  • 跨平台 - 使用 Delphi 和 Free Pascal 编译

MCP能力

  • 工具 - 注册带有 JSON 模式验证和 listChanged 通知的自定义工具
  • 资源 - 基于URI的访问列表、阅读、模板和订阅
  • 提示词 - 列出并获取多种内容类型(文本、图片、音频、资源)
  • 日志 - setLevel 方法,采用 RFC 5424 日志级别
  • 补全 - 提示和资源的论元自动补全

传输层

本页由 AI 翻译,技术细节请以原文为准。

README

以下为原文 README 节选,完整内容请查看原文。

mORMot2 MCP Server

🇪🇸 Leer en español

High-performance Model Context Protocol (MCP) server implementation using the mORMot2 framework.

Implements MCP Specification 2026-07-28 (stateless per-request model, server/discover, subscriptions/listen) with full backward compatibility with initialize-based clients (2024-11-05 through 2025-11-25) and bidirectional notifications via SSE.

Features

Core

  • Pure mORMot2 implementation - No external dependencies beyond mORMot2
  • Dual transport support - stdio and HTTP with SSE
  • JSON-RPC 2.0 - Full protocol support using TDocVariant
  • Modular architecture - Easy to extend with custom tools, resources, and prompts
  • Cross-platform - Compiles with Delphi and Free Pascal

MCP Capabilities

  • Tools - Register custom tools with JSON Schema validation and listChanged notifications
  • Resources - List, read, templates, and subscriptions with URI-based access
  • Prompts - List and get with multiple content types (text, image, audio, resource)
  • Logging - setLevel method with RFC 5424 log levels
  • Completion - Argument auto-completion for prompts and resources

Transport Layer

  • stdio transport - JSON-RPC newline-delimited, logs to stderr
  • HTTP transport - REST API with Server-Sent Events (SSE), CORS, and TLS support
  • Session management - Cryptographic session IDs (128-bit)
  • SSE notifications - Real-time bidirectional communication
  • Keepalive - Configurable SSE keepalive (default 30s)
  • Graceful shutdown - SIGTERM/SIGINT handling with 5s timeout
  • Event bus - Thread-safe pub/sub for internal notification routing

Notifications

  • notifications/tools/list_changed - Tool registration changes
  • notifications/resources/list_changed - Resource changes
  • notifications/resources/updated - Subscribed resource updates
  • notifications/prompts/list_changed - Prompt changes
  • notifications/message - Log messages
  • notifications/progress - Progress updates
  • notifications/cancelled - Request cancellation

Requirements

  • mORMot2 framework
  • Delphi 10.3+ (tested) or Free Pascal 3.2+ (not yet tested)

Project Structure

mORMot-MCP-Server/
├── MCPServer.dpr           # Delphi project
├── MCPServer.lpr           # Free Pascal project
├── MCPServer.lpi           # Lazarus project
├── src/
│   ├── Core/
│   │   ├── MCP.Manager.Registry.pas   # Manager registration
│   │   └── MCP.Events.pas             # Event bus (pub/sub)
│   ├── Protocol/
│   │   └── MCP.Types.pas              # Core types and settings
│   ├── Transport/
│   │   ├── MCP.Transport.Base.pas     # Transport abstraction
│   │   ├── MCP.Transport.Stdio.pas    # stdio transport
│   │   └── MCP.Transport.Http.pas     # HTTP + SSE transport
│   ├── Server/
│   │   └── MCP.Server.pas             # Legacy HTTP server
在 GitHub 查看完整 README

安装

This server does not publish a one-line install command.

Open the repository installation guide 新手?先看 mcpskill.org 教程 →

配置

{ "mcpServers": { "mormot-server": { "command": "C:\\path\\to\\MCPServer.exe", "args": ["--transport=stdio"] } } }