Skip to content

About

Building MCP servers with Delphi

Topics

Resources

Stars

49 stars

Watchers

4 watching

Forks

Latest commit

 

History

283 Commits

Folders and files

Repository files navigation

MCPConnect

🔌 MCPConnect: A Delphi MCP Server Library

A powerful, attribute-driven framework for building Model Context Protocol (MCP) Servers in Delphi.

Note

Support for the MCP specification version 2026-07-28 is currently under development in the feature/mcp-2026-07-28 branch.

Getting Started

Please follow the documentation at mcpconnect.delphiblocks.dev!

In-depth notes in this repository:

  • OAuth 2.1: bearer-token authentication, token validators, JWKS and the metadata proxy.
  • WebMCP in MCPConnect: offering your tools to the AI agent built into the browser, and how a call reaches the server.
  • WebMCP + MCP server vs a REST server: why one set of tools serves pages, browser agents and external agents, and how to secure it.

✨ What is MCP?

The Model Context Protocol (MCP) is an open standard for connecting large language models (LLMs) to external tools and data.

It enables AI models to go beyond their training data by accessing new information, performing actions, and interacting with tools and databases.

With MCP servers you can:

  • Provide functionality through Tools (used to execute code or otherwise produce a side effect)
  • Expose data through Resources (used to load information into the LLM’s context)
  • Define interaction through Prompts (reusable templates for LLM interactions)

⚡ Highlights

Delphi MCP Connect (MCPConnect) is a lightweight yet robust framework designed to drastically simplify the creation of Model Context Protocol (MCP) Servers using Embarcadero Delphi. By leveraging the power of Attributes, the framework allows developers to re-use existing business logic and standard Delphi classes, turning them into protocol-aware server components with minimal boilerplate code. MCPConnect handles the serialization, routing, and context management required for the server-side implementation of the MCP protocol.

  • 🛡️Type safety - Define your tool arguments as native delphi class or records, have mcp-connect handle the rest.
  • 🚛 Transports - Built-in HTTP (WebBroker, Indy) and STDIO transports for both stateless and persistent connections.
  • 🗂️ Session Management - Built-in stateful session support across requests with automatic cleanup and custom session data.
  • 🔐 OAuth 2.1 — Built-in support for OAuth 2.1 bearer-token authentication following the MCP Authorization specification, with pluggable token validators, JWKS key management, and a metadata proxy for providers that don't fully advertise PKCE support.
  • 🌐 WebMCP - Offer your MCP tools to the AI agent built into the visitor's browser, on the pages your server renders (for example with WebStencils). Tag an [McpTool] with webmcp and each page chooses which tools it offers; calls go through your /mcp endpoint with the visitor's session, so the same tools, authorization and rules apply. Prototype: WebMCP is a W3C draft browser API. See WebMCP in MCPConnect.
  • ⚡ Low boilerplate - mcp-connect generates all the MCP endpoints for you apart from your tools, prompts and resources.

💡 Usage Example

Creating an MCP-enabled service is as simple as adding the required attributes to a standard Delphi class and methods.

Register the class (the Model) and use the [McpTool] attribute for the methods (the Tools or actions).

unit Demo.HelpDeskService;

interface

uses
  System.SysUtils, 
  MCPConnect.MCP.Attributes;

type
  THelpDeskService = class
  public
    // This method is published as an MCP tool
    [McpTool('doclist', 'List all the available documents')]
    function ListDocument(
      [McpParam('category', 'Document Category')] const ACategory: string
    ): TContentList;
    
    // This method is NOT exposed because it lacks the [McpTool] attribute
    procedure InternalStuff;
  end;

🤖 Claude Code Plugin

A Claude Code plugin for MCPConnect is available from the delphi-blocks/claude-plugins marketplace. Installing it teaches Claude Code how MCPConnect actually works — transports, attributes, the fluent configuration, sessions, notifications and OAuth — so it can scaffold a new server or add tools, resources and prompts to an existing one without you pasting the API in every time.

/plugin marketplace add delphi-blocks/claude-plugins
/plugin install mcpconnect@delphi-blocks

The skill activates on its own whenever you are working with MCPConnect.


🤝 Contributing

We welcome contributions! If you have suggestions, bug reports, or want to contribute code, please:

  1. Fork the repository.
  2. Create a new branch (git checkout -b feature/AmazingFeature).
  3. Commit your changes (git commit -m 'Add some AmazingFeature').
  4. Push to the branch (git push origin feature/AmazingFeature).
  5. Open a Pull Request.

📄 License

Distributed under the MIT License. See LICENSE for more information.

About

Building MCP servers with Delphi

Topics

Resources

Stars

49 stars

Watchers

4 watching

Forks

Releases

Packages

Contributors

Languages