MCP & Agentic AI with Delphi

From the MCP protocol to an AI agent embedded in the management software, with mcp-server-delphi and DMVCFramework.

Duration: 2 days| Price: € 699,00 VAT excluded

Description
A single application grows module by module, from the minimal MCP server to the embedded agent in the executable. Each step remains a standalone project on disk: by the end of the course, one version per step.
What you will know how to do by the end
  1. Explain what an LLM does and does not do, and why without tools it remains an inert text generator.
  2. Build an MCP server in Delphi with attributes and RTTI, without writing JSON schema by hand.
  3. Expose FireDAC queries, objects, collections, and media as results that the model interprets.
  4. Choose between stdio and HTTP transport, with implications for deployment, sessions, and security.
  5. Run an embedded agentic loop inside the Delphi application, using the chosen model, cloud or on-premises.
  6. Expose DMVCFramework REST APIs already in production as MCP tools, without rewriting them.
  7. Secure an agent with write tools: read/write separation, human approval, audit, and defenses against prompt injection.
  8. Test an MCP server with deterministic evals, not trial-and-error.
  9. Apply the method to your own ERP/management software: which tools to expose first, how to describe them, where to set limits.
Hardware and software prerequisites
Hands-on course: you write code from the very first lab.

Hardware

  • Administrator privileges, or the ability to install software and open outgoing Internet connections.
  • Approximately 10 GB of free disk space, plus space for any local model if used. 

Software

  • Delphi 11 Alexandria or later, Professional/Enterprise/Architect (or Trial, not Community).
  • Git
  • DMVCFramework 3.5.x, installed in Delphi and operational.
  • mcp-server-delphi, cloned and buildable.
  • An MCP client: Claude Desktop, Gemini CLI, Claude Code, or Continue. Required starting from module M3.
  • Sample database, Firebird embedded or PostgreSQL: customers, items, orders, order lines, pre-populated test data. Another database engine can also be used, but the examples will use PostgreSQL with the sample schema. 

For agentic modules, from M6 onwards

Course examples use models available on OpenRouter: just a personal key is needed, no other configuration.

  • OpenRouter, essential for following the labs: a personal key, OpenAI-compatible endpoint. Token usage for the labs costs just a few euros over the two days.
  • Local model, optional, in addition: Ollama, vLLM, or llama.cpp –api, pre-downloaded before the course. Many local models running on consumer hardware cannot handle the multi-step tool calling used in the course: they are fine for direct comparison, but not for following the labs instead of OpenRouter.

No earlier than one week before the course, the setup checklist for your machine will be sent by email along with a verification project: if it compiles and prints MCP OK, your environment is ready. If setup fails: write to us before the course, not on day one.

For on-site corporate editions, setup is arranged directly with the workstation administrators.

Day 1 · From the protocol to the MCP server

Objective: by the end of the day, a real AI client calls the tools written by the participant, operating on the sample database.

Morning 09:30-13:00, afternoon 14:00-17:30. Fixed sequence of modules, duration adapted to classroom composition.

 

Initial Demo and Roadmap

We start from the end, before any explanation.

  • Live demo: a request in Italian to a Delphi executable, which queries the database, checks credit limit, prepares a reorder draft, and pauses to ask for human confirmation before writing.
  • Reading the demo’s source code, without commentary: standard units, with attributes.
  • Map of the twelve modules and the goal of each one.

Agentic AI in Half an Hour

The minimum necessary theory, without mathematics, written for developers.

  • What an LLM does: next-token prediction, the source of both surprising results and hallucinations.
  • Context window, tokens, cost: the metrics that determine whether an agentic idea is sustainable.
  • Tool use: the model requests, it does not execute. Execution remains with the participant’s code, with its own permissions.
  • The agentic loop in five steps: prompt, tool request, execution, result sent back to the model, repeat until complete.
  • Chatbot vs. agent: the ability to chain multiple calls decided at runtime, not at design time.
  • Local vs. cloud models: when on-premises makes sense, and why many local models on consumer hardware cannot handle multi-step tool calling like the one used in the course.


The MCP Protocol

Before MCP, every LLM/software integration was single-use code.

  • Architecture in three roles: Host, Client, Server.
  • The three primitives: tool (callable functions), resource (readable data), prompt (reusable templates), with ERP examples.
  • Session lifecycle: initialize, capability negotiation, tool discovery, calls.
  • The two transports in the specification: stdio and Streamable HTTP.
  • RTTI and attributes: JSON Schema for tools generated from the method signature, no configuration files to manually keep in sync.
  • Overview of mcp-server-delphi: server, client, agent, REST bridge, a single Apache 2.0 library built on DMVCFramework.


Your First MCP Server (Lab)

First lab: from project setup to connecting with a real AI client.

  • Project from scratch using the stdio quickstart, or line by line.
  • The first tool: the MCPTool and MCPParam attributes.
  • Provider registration and RTTI discovery.
  • Stdio discipline: what can be written to standard output and where logging goes.
  • Connecting to Claude Desktop / Gemini CLI: configuration file, launching the child process, tool verification.
  • Tool descriptions: how to write them for a model, not for a colleague.
  • Deliverable: Working MCP server, under one hundred lines, connected to a real AI client.


Feature-Rich Server (Lab)

From prototype to something resembling business software. The longest module of the course.

  • Typed parameters: integers, floats, booleans, dates, enumerations, mapped to JSON Schema.
  • Optional parameters with TMCPParamPresence.Optional.
  • Validation: where to place it, difference between a declared error and an exception.
  • The TMCPToolResult family: Text, FromValue, JSON, FromObject, FromRecord, FromCollection, FromDataSet, Image, Audio, FromStream, Resource, ResourceBlob, Error.
  • FromDataSet: from an existing TFDQuery to the JSON that the model reads.
  • Resources: documentation, price lists, configurations, using URI templates.
  • Reusable prompts with arguments, for recurring company instructions.
  • Lab: five or six tools on the sample database (customer search, order history, item availability, sales statistics), connected to the AI client, handling prompts that require multiple tools sequentially.


HTTP and the First Architectural Decision

Same server, second transport.

  • From stdio to Streamable HTTP using PublishObject, an idiomatic DMVCFramework pattern.
  • Sessions, concurrency, automatic cleanup.
  • Dual transport within the same executable: when it makes sense.
  • The architectural decision—product-driven before technical: who launches the server, deployment, authentication, multi-user scenarios.
  • A question left open until Day 2.
Day 2 · From Agent to Production
Objective: intelligence moves inside the executable, with everything needed for an agent to interact with real data.

Morning 09:30-13:00, afternoon 14:00-17:30. This is a workshop focused on the participants’ software: in corporate editions it tends to run longer, and modules are adjusted accordingly.

From Server to Agent (Lab)

The core module of the course. Yesterday’s server, this time controlled directly by the application.

  • TMCPClient (HTTP) and TMCPStdioClient (child process via pipe): the Delphi application consuming third-party MCP servers.
  • Runtime tool discovery, invocation, and error handling.
  • Scenario: consuming an external MCP server, such as VAT verification or a document repository.
  • TMCPOpenAIAgent: complete loop, discovery, round-trips with the model, dispatching, and token accounting.
  • Endpoint configuration: OpenAI, OpenRouter, or a local model. Changing a string, not the architecture.
  • System prompt as a project artifact: versioned, reviewed, and tested.
  • MaxTurns and costs: placing a cap on model round-trips.
  • Agent over stdio transport using SetMCPClient.
  • Synchronous and blocking Run: UI implications.
  • Streaming responses: Streaming and OnContentDelta.
  • Advantages and limitations of an embedded agent compared to an external client.
  • Lab: VCL form with an input field and output panel. Request in natural language, the agent uses the tools built the previous day.

Trust and Security

The module that determines whether the project makes it into production.

  • An agent’s attack surface: untrusted input, tools with side effects, personal data in context.
  • Prompt injection: concrete ERP examples and actionable defenses.
  • Golden rule: read-only first, write operations second.
  • Human-in-the-loop: implementing human confirmation in Delphi before executing write actions.
  • GDPR and personal data: cloud vs. on-premises models, data minimization in tools, and privacy disclosures.
  • Auditing: what needs to be logged for every tool call and why.
  • Security checklist to serve as a quality gate before every release.

Reliability and Trust Engineering

Case study: mcp-firebird, a production MCP server on a Firebird database.

  • The Guard pattern: how mcp-firebird isolates database access, traces calls, and converts exceptions into model-readable errors.
  • Explicit limits in tools: row caps, timeouts, operation whitelists, and unexposed fields.
  • Deterministic evals: testing non-deterministic systems. The library itself as an example: four independent compliance suites, over four hundred total cases.
  • Observability: structured logging, token usage tracking, and per-tool response times.
  • Graceful degradation: unreachable models, incorrect responses, missing requested tools.
  • Tool versioning: impact on saved conversations when a signature changes.

AgenticERP Deconstructed

The full demo dismantled step-by-step: an executable acting simultaneously as an agent and MCP server at enterprise scale.

  • Overall architecture and rationale behind each technical decision.
  • Organizing tools by business domain rather than database tables.
  • Long context management: what to keep, summarize, or discard.
  • Confirmation workflow in a real VCL application.
  • What failed during the initial attempt, and why.


Your First Agent on Your ERP (Lab)

Workshop: working on the participants’ actual software instead of sample data.

  • Identifying candidates: slow, repetitive tasks crossing multiple UI screens.
  • The three-tool method: starting with three read-only tools on the most critical pain point, not thirty.
  • Writing descriptions: when to use the tool, when to avoid it, and what it returns.
  • REST → MCP Bridge: scanning engine routes via RTTI and exposing them as MCP tools. What to expose, filter out, and how to refine generated descriptions.
  • From bridge to generated code: GenerateProviderUnit outputs the provider unit to be versioned and refined manually.
  • First use case for management presentation: a short, verifiable demo on real data.
  • Deliverable: for each participant (or group in corporate editions), three tools, their descriptions, and the initial execution scenario.


Production and Beyond + Q&A

  • Costs: estimating per-user monthly expenditure, cost-reduction strategies (smaller models for simple tasks, shorter context windows, caching), and on-premises viability threshold.
  • Deployment: agent execution environment, distributing tool updates, and managing API keys outside source control.
  • Model selection: tool calling requirements, evaluating performance on your domain in half a day instead of relying on generic benchmarks.
  • Internal governance: approving new tools, reviewing system prompts, and collecting user feedback.
  • Roadmap: future direction of MCP and library evolution.
  • Open Q&A; in corporate editions, initial collective review of the use cases brought by participants.
Materials provided
  • All lab projects, step-by-step, fully buildable and commented.
  • Course slides in PDF format.
  • Security and production checklists, formatted for use as release gates.
  • Annotated system prompt template, ready to adapt to your domain.
  • Sample database schema with pre-populated test data.
  • Access to the mcp-server-delphi repository and official documentation, available even after the course.
  • Thirty days of email support.
Variations
The corporate edition, on-site or dedicated remote, follows the same syllabus and sample database as the standard course: only the location and schedule change, dedicated to a single company. During the module, participants design their first tools for their own software, rather than the course sample software. Upon request and by agreement with the company, any part of the program can be expanded or reduced. The standard edition has an open schedule, a shared sample database, and a maximum of twelve participants. To take the tools designed during the course and implement them on the client’s real database and APIs, separate post-course mentoring is available: one or more agreed-upon days where the first tools are co-developed directly on the production codebase and brought all the way through testing.
Useful links
Scroll to Top