Become a member!

MCP Server for DMVCFramework: Connect Your Delphi Applications to Artificial Intelligence

๐ŸŒ
This article is also available in other languages:
๐Ÿ‡ฎ๐Ÿ‡น Italiano  โ€ข  ๐Ÿ‡ช๐Ÿ‡ธ Espaรฑol  โ€ข  ๐Ÿ‡ฉ๐Ÿ‡ช Deutsch  โ€ข  ๐Ÿ‡ง๐Ÿ‡ท Portuguรชs

Imagine being able to ask your AI assistant: “What is the product that generated the most revenue in March?” โ€” and the answer comes directly from your business application, with real, up-to-date data, without making anything up. Or saying: “Create a purchase order for 200 units of product XYZ from supplier Rossi” โ€” and the order is actually created in the system, with all the proper validation checks. No complex integration, no middleware to configure, no REST API to expose manually.

Today this is possible thanks to MCP Server for DMVCFramework: an open source library that transforms any Delphi application into an MCP server, the standard protocol that AI assistants like Claude, Gemini, and ChatGPT use to communicate with external software.

MCP Server for DMVCFramework


What Is the Model Context Protocol?

The Model Context Protocol (MCP) is an open standard created by Anthropic that defines how an AI assistant can interact with external software. Think of it as a universal plug: a single protocol that works with any compatible AI client โ€” Claude Desktop, Claude Code, Google Gemini CLI, Continue, Cursor, and many others.

The protocol defines three types of capabilities that a server can expose:

  • Tool โ€” functions the AI can call: query a database, generate a report, send an email, perform a calculation
  • Resource โ€” data the AI can read: configurations, documents, metrics
  • Prompt โ€” reusable conversation templates that guide the AI’s behavior

The MCP server takes care of everything else: sessions, JSON-RPC, JSON schema for parameters, error handling. You focus only on the business logic.

The Golden Gate Bridge in the fog โ€” like MCP Server for DMVCFramework, a bridge connecting the world of Delphi applications to artificial intelligence Photo by Rockwell on Unsplash


Why DMVCFramework? Because It Already Has Everything

The choice of DMVCFramework as the platform for an MCP server is not accidental โ€” it is the natural choice. The MCP protocol is based on JSON-RPC 2.0 for communication and HTTPS for network security. DMVCFramework has already offered both for years in production, with battle-tested infrastructure:

  • Native JSON-RPC 2.0 โ€” DMVCFramework implements JSON-RPC as a first-class citizen, with PublishObject, automatic routing, and complete serialization of Delphi types
  • Built-in HTTPS โ€” full TLS support via TaurusTLS, with certificate management and .env configuration
  • Sessions and security โ€” middleware for authentication, thread-safe session management, JWT

In practice, everything needed to implement an MCP server was already present in DMVCFramework. This library is simply the bridge that connects this infrastructure to the MCP protocol, adding automatic discovery via RTTI and the attributes that make everything so straightforward.

From Weeks to Minutes

Until now, integrating an existing system with an AI assistant meant building REST adapters, writing platform-specific plugins, managing authentication and different formats. With MCP Server for DMVCFramework, just a few lines of Delphi code are enough to expose functionality that any AI client can use immediately.

What previously required weeks of work now takes just a few minutes.

The simplicity is stunning

Want to expose a function from your business application to AI? Here is all the code you need:

type
  TERPTools = class(TMCPToolProvider)
  public
    [MCPTool('fatturato_prodotto', 'Restituisce il fatturato di un prodotto per mese')]
    function FatturatoProdotto(
      [MCPParam('Codice prodotto')] const CodiceProdotto: string;
      [MCPParam('Mese (1-12)')] const Mese: Integer;
      [MCPParam('Anno')] const Anno: Integer
    ): TMCPToolResult;
  end;

function TERPTools.FatturatoProdotto(
  const CodiceProdotto: string; const Mese, Anno: Integer): TMCPToolResult;
var
  LQuery: TFDQuery;
begin
  LQuery := TFDQuery.Create(nil);
  try
    LQuery.Connection := GetERPConnection;
    LQuery.SQL.Text :=
      'SELECT SUM(Quantita * PrezzoUnitario) as Fatturato ' +
      'FROM DettaglioOrdini d JOIN Ordini o ON d.IDOrdine = o.IDOrdine ' +
      'WHERE d.CodiceProdotto = :codice ' +
      'AND MONTH(o.DataOrdine) = :mese AND YEAR(o.DataOrdine) = :anno';
    LQuery.ParamByName('codice').AsString := CodiceProdotto;
    LQuery.ParamByName('mese').AsInteger := Mese;
    LQuery.ParamByName('anno').AsInteger := Anno;
    LQuery.Open;
    Result := TMCPToolResult.FromDataSet(LQuery);
  finally
    LQuery.Free;
  end;
end;

initialization
  TMCPServer.Instance.RegisterToolProvider(TERPTools);

This is everything. No configuration files, no XML, no JSON to write by hand. The library discovers the tool via RTTI, automatically generates the JSON schema for the parameters, and makes it available to any AI that connects.


๐Ÿ’ก Usage Scenarios: The Possibilities Are Endless

The beauty of MCP is that it is not limited to a single use case. Any system that currently exposes data or functionality can become an MCP server. Here are some concrete scenarios:

ERP and Business Management Systems

AI becomes a conversational interface for your business application:

  • “Show me the customers with invoices overdue by more than 30 days”
  • “What is the average margin on products in category X?”
  • “Create a purchase order for 500 units of product ABC from supplier Rossi”

No new dashboards needed. No additional reports needed. The user asks, the AI queries the business application and responds.

Monitoring and Industrial Automation Systems

  • “What is the average temperature of furnace 3 over the last 24 hours?”
  • “Have there been any alarms in the packaging department today?”
  • “Compare this week’s production with last week”

AI accesses SCADA/MES data through MCP tools, making analysis immediate.

Healthcare and Clinical Management

  • “How many patients does Dr. Bianchi have scheduled tomorrow?”
  • “Show me patient Rossi’s test results from the last month”
  • “Which medications are running low in the pharmacy warehouse?”

Natural access to clinical data, with all the security guarantees your system already implements.

Documentation and Knowledge Base

Expose your product documentation as MCP resources. The AI will be able to search, navigate, and directly cite your manuals, FAQs, and operating procedures.

DevOps and Internal Tooling

  • “What is the status of the deployment on the production server?”
  • “Show me the errors in the log from the last fifteen minutes”
  • “How many requests per second is the payment API handling?”

Every internal tool, every script, every operating procedure becomes an MCP tool that AI can orchestrate.


Authentication and Authorization: Nothing Changes

A natural question that arises is: “But if the AI can call my tools, who controls who can do what?”

The answer is simple: your application, just as it always has. The MCP server lives inside your DMVCFramework application, so all the security infrastructure you already have continues to work exactly as before.

In practice, the /mcp endpoint is a DMVCFramework endpoint like any other. This means you can protect it with the same mechanisms you already use for your REST APIs:

  • Authentication middleware โ€” JWT, Basic Auth, API Key, OAuth2, or any custom middleware you already have
  • Access control โ€” verify user permissions inside your tools, exactly as you do in your REST controllers
  • HTTPS โ€” the HTTP transport supports TLS, so communication is encrypted

There is no “parallel” security system to learn or configure. If your business application today verifies that user X can only see orders from department Y, that same logic applies identically when AI calls the MCP tool on behalf of that user. The tool is Delphi code in your application โ€” it can access the session context, verify roles, apply data filters, exactly like any other part of your system.

And if your system is not based on DMVCFramework? No problem. Even using stdio transport โ€” where there is no HTTP server โ€” your tools remain Delphi code running inside your application. You can query the same user database, call the same permission-checking stored procedures, apply the same authorization logic your system already implements. The MCP tool is simply a new entry point, but the security and business logic remains yours.


Two Transports, Zero Compromises

The library supports two transport modes:

Streamable HTTP

Your server listens on the network. AI clients connect via HTTP โ€” ideal for production environments, centralized servers, multi-station access.

QuickStart.exe --transport http
# Server listening on http://localhost:8080/mcp

stdio

The AI client (e.g., Claude Desktop) directly launches your executable and communicates via stdin/stdout. No HTTP dependency โ€” no TaurusTLS, Indy, or WebBroker needed. The binary is lightweight and self-contained.

{
  "mcpServers": {
    "mio-erp": {
      "command": "C:\\MioGestionale\\MCPServer.exe"
    }
  }
}

Both transports share the same code for providers โ€” write your tools once and they work everywhere.


๐Ÿš€ Quick Start: From Zero to MCP Server in 5 Minutes

The repository includes Quick Start projects ready to use. Copy the folder, customize the providers, compile, and your MCP server is up and running.

samples/
โ”œโ”€โ”€ shared/                      โ˜… Your tools, resources, and prompts
โ”‚   โ”œโ”€โ”€ ToolProviderU.pas
โ”‚   โ”œโ”€โ”€ ResourceProviderU.pas
โ”‚   โ””โ”€โ”€ PromptProviderU.pas
โ”œโ”€โ”€ quickstart/                  HTTP + stdio project
โ””โ”€โ”€ quickstart_stdio/            stdio-only project (no TaurusTLS)

Each provider file is richly commented explaining exactly how to add new tools, resources, and prompts. You don’t need to read a 200-page manual โ€” open the file, read the comments, modify it, and compile.

The project is on GitHub under the Apache 2.0 license: github.com/danieleteti/mcp-server-delphi


Add MCP to an Existing DMVCFramework Application

If you already have a DMVCFramework application in production, adding MCP is a matter of two lines in your Web Module:

fMVC.AddController(TMCPSessionController);
fMVC.PublishObject(
  function: TObject
  begin
    Result := TMCPServer.Instance.CreatePublishedEndpoint;
  end, '/mcp');

Your REST endpoints, WebSockets, everything else continues to work exactly as before. MCP is simply an additional endpoint that coexists with everything you already have.


๐ŸŽค ITDevCon 2026 SE: In-Depth Live Session

I will be speaking in depth about this project at the upcoming ITDevCon 2026 Special Edition, which will be held in person on May 8, 2026, in Rome.

We will explore together:

  • How to design effective MCP tools for real-world systems
  • Patterns and best practices for exposing complex business logic
  • Live demo of integration with Claude Desktop and other AI clients
  • How to structure an MCP project for enterprise applications
  • Dual-transport architecture and deployment scenarios

If you are thinking about integrating AI into your Delphi systems, this session will give you all the tools to get started. Register at itdevcon.it.


๐Ÿ“š Upcoming Courses

For those who want to go deeper and make their system’s data and business logic available to AI assistants, dedicated courses on this project will be available soon.

The courses will cover:

  • Fundamentals of the MCP protocol
  • Designing tool providers for business management systems
  • Resource and Prompt providers for corporate knowledge bases
  • Deployment and security in production environments
  • Advanced scenarios: multi-content, serialization, error handling

More details will be announced in the coming weeks. Stay tuned and keep an eye on the training page!


The Possibilities Are Endless

With MCP Server for DMVCFramework, every Delphi application becomes an access point for artificial intelligence. We are not talking about a proof-of-concept or an experiment: we are talking about a standard protocol, supported by all major AI assistants, with a production-ready library built on DMVCFramework’s battle-tested infrastructure.

Think about what this means:

  • Your business application responding to questions in natural language
  • Your data fueling sophisticated AI analyses
  • Your business logic becoming accessible without building new interfaces
  • Your services integrating with the global AI ecosystem

And all of this with the language and framework you already know and use every day.

The future of AI integration is here, and it is written in Delphi.


Comments

comments powered by Disqus