Blog
All Blog Posts | Next Post | Previous Post
Add AI superpower to your Delphi & C++Builder apps part 4: create MCP servers
Sunday, May 25, 2025
Image generated by Deepai.org
This is already part 4 in our article series about adding AI superpower to your Delphi & C++Builder apps. In the first 3 installments, we covered:
In this article, we dive into the world of MCP. If MCP is unknown to you, don't worry, we'll explain it to you. Be assured, it is a term you'll hear a lot in the coming years. The Model Context Protocol (MCP) is an open standard, open-source framework introduced by Anthropic to standardize the way artificial intelligence (AI) models like large language models (LLMs) integrate and share data with external tools, systems, and data sources.
In this article, we'll explore:
-
What MCP servers are,
-
The problems they solve,
-
The benefits they bring to software architectures,
-
Why Delphi developers should care,
-
And how the TTMSMCPServer class makes building MCP servers in Delphi easier than ever, including tool handlers for your business logic.
What is an MCP Server?
An MCP Server is a server application that implements the Model Context Protocol (MCP). MCP is a command-based protocol that allows clients and servers to exchange structured, versioned commands with clearly defined data types, properties, and results.
Think of an MCP server as a central hub that:
-
Accepts incoming commands from clients,
-
Processes these commands based on registered tools (units of functionality),
-
Responds with structured data,
-
And optionally notifies clients about resources, prompts and tools dynamically.
The transport layer for MCP can be stdio, HTTP SSE, HTTP streaming... over which the JSON RPC protocol is implemented.
Why MCP? What Problems Does it Solve?
Modern software systems face several challenges:
-
Versioning: APIs evolve over time. MCP's versioned commands ensure backward compatibility.
-
Self-Describing APIs: MCP servers expose metadata (tools, properties, types) that clients can query dynamically. No need for external API documentation!
-
Extensibility: New tools and capabilities can be added to the server without breaking existing clients.
-
Structured Communication: MCP provides a standardized way to handle data types, errors, and responses across systems.
-
Mixing containerized LLM extensions : As multiple MCP servers can be simultanously used by the LLM via the MCP client, different containerized sets of functions become available to the LLM.
By adopting MCP:
-
You can augment data & functionality of the AI with a variety of functionality via different MCP servers.
-
Clients can discover available features dynamically.
-
Your server remains future-proof and easy to extend.
Why MCP Matters for Delphi Developers
Delphi is known for its productivity, RAD approach, and strong type system. However, integrating modern protocols like REST or gRPC often requires boilerplate code and third-party libraries.
With MCP, Delphi developers get:
-
A native, Pascal-friendly way to build modern, dynamic APIs that augment LLMs.
-
A protocol that aligns naturally with Delphis strongly-typed object model.
-
The ability to rapidly prototype and extend servers without worrying about breaking existing clients.
-
A lightweight, efficient alternative to REST/gRPC for internal services, tools, and developer utilities.
Introducing TTMSMCPServer: Build MCP Servers in Minutes
To make MCP development accessible for Delphi developers, we've created the TTMSMCPServer class in TMS AI Studio. This class abstracts away the complexities of MCP and lets you focus on building tools and handling commands.
Heres how easy it is to set up an MCP server:
This setup:
- Names your server,
- Specifies its version,
- Enables tool/resource notifications for clients,
- Registers its tools & resources dynamically.
Adding Tools with Business Logic
A tool in MCP is a logical unit of functionality your server exposeslike an API endpoint. As we explained LLM function calling in article 2, think of MCP servers as self-describing providers of functions LLMs can call. With TTMSMCPServer, creating tools is straightforward and handler methods allow you to add the core logic.
Here's a full example that includes a tool handler for getting weather information based on a city:
This Handler:
-
Receives the arguments passed to the tool (
Args
), -
Extracts the city,
-
Calls a backend API or business logic (
CallWeatherAPI
) to fetch the weather, -
And returns the result as a
TValue
.
This pattern allows you to:
-
Define input properties (function arguments) declaratively,
-
Implement custom logic for each tool in a single place,
-
And keep your server code clean, modular, and maintainable.
This server can be built as a command-line tool. Building it, we get an EXE file and we can configure this MCP server in several of the well-known MCP Client applications, such as the Claude AI desktop tool, Visual Studio Code, Cursor.ai, ... and much more.
One the client runs the MCP server, it knows the tools, resource, prompts etc... the MCP server provides, can communicate this to the LLM and the LLM will execute the tools when it judges it needs these.
Claude desktop tool showing the MCP servers configured and running
Declarative Fluent/Builder Pattern Style vs Classic OOP Style
Note that the code presented above uses the declarative fluent or builder pattern style. But our MCP library can also be used in a classic OOP style. For example, server creation and adding a tool then becomes:
So, with both programming styles offered in the TMS AI Studio, you can choose what style you use and we are very curious to hear which programming style you prefer and why!
Use cases for us Delphi developers
By using TTMSMCPServer, Delphi developers can:
-
Build modern, dynamic server applications offering to the LLMs database access, REST APIs, access to own data file formats, internal data structures, sensor data and so much more
-
Expose powerful APIs with minimal boilerplate
-
Handle business logic cleanly via tool handlers
-
And stay future-ready with MCPs built-in versioning and extensibility.
Conclusion
MCP servers are a powerful way to containerize our own functionality to augment the power of the LLMs. LLMs can be given access to our own data or given the means to execute code in our own application domain.
In upcoming articles, well dive deeper into building an MCP client with Delphi & using RAG.
If you have an active TMS ALL-ACCESS license, you can now get also access to the first test version of TMS AI Studio that uses the TTMSFNCCloudAI
component but also has everything on board to let you build MCP servers and clients.
Register now to participate in this testing via this landing page.
Bruno Fierens
Related Blog Posts
-
Add AI superpower to your Delphi & C++Builder apps part 1
-
Add AI superpower to your Delphi & C++Builder apps part 2: function calling
-
Add AI superpower to your Delphi & C++Builder apps part 3: multimodal LLM use
-
Add AI superpower to your Delphi & C++Builder apps part 4: create MCP servers
-
Add AI superpower to your Delphi & C++Builder apps part 5: create your MCP client

This blog post has not received any comments yet.
All Blog Posts | Next Post | Previous Post