/mars-curiosity:mars-mcp-serverfrom MARS-Curiosity
Builds MCP (Model Context Protocol) servers in Delphi with MARS-Curiosity, enabling AI agents to discover and call Delphi code as tools, read resources, use prompts, and show interactive views.
Ships in MARS-Curiosity. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
MARS ships native MCP support (units MARS.MCP.* in Source/): derive a resource from TMCPResource, mark methods with [MCPTool], and any MARS server becomes an MCP server speaking the Streamable HTTP transport (single endpoint, JSON-RPC 2.0 over POST). Tool list and JSON Schema are generated from RTTI — no protocol code to write.
The complete working example is Demos/MCPServer in the MARS repository (public tools + FireDAC-backed authenticated tools + OAuth).
MCP servers are built on resources (TMCPResource), also in projects that define their REST endpoints as routes (MARS.Core.Routes, MARSTemplateRoutes): routes are an addition to resources, and an MCP resource lives next to them in the same application. Add it to the application's resources ('Server.Resources.*' mask) as shown below.
unit Server.Resources.MCP;
interface
uses
SysUtils, Classes
, MARS.Core.Attributes, MARS.Core.MediaType
, MARS.MCP.Resource, MARS.MCP.Attributes;
type
TCalculationResult = record
operation: string;
value: Double;
end;
[Path('mcp')
, MCPServerInfo('My MCP Server', '1.0.0'
, 'Optional instructions the AI agent reads on connection.')]
TMyMCPResource = class(TMCPResource)
public
[MCPTool('say_hello', 'Returns a friendly greeting for the given name')]
function SayHello(
[MCPParam('name', 'Name of the person to greet')] const AName: string): string;
[MCPTool('add_numbers', 'Adds two numbers and returns a structured result')]
function AddNumbers(
[MCPParam('a', 'First operand')] const A: Double;
[MCPParam('b', 'Second operand')] const B: Double): TCalculationResult;
end;
implementation
uses
MARS.Core.Registry;
function TMyMCPResource.SayHello(const AName: string): string;
begin
Result := 'Hello, ' + AName + '!';
end;
function TMyMCPResource.AddNumbers(const A, B: Double): TCalculationResult;
begin
Result.operation := 'add';
Result.value := A + B;
end;
initialization
MARSRegister([TMyMCPResource]);
end.
This is a regular MARS resource: register the unit mask in Server.Ignition.pas as usual (AddApplication('DefaultApp', '/default', ['Server.Resources.*'])). The MCP endpoint is the composed URL, e.g. http://localhost:8080/rest/default/mcp. Everything the mars-development skill says about resources, [Context] injection and configuration applies here too.
A complete starting unit is available in assets/Server.Resources.MCP.pas.template.
| Attribute | Where | Effect |
|---|---|---|
MCPServerInfo(name, version, instructions) | resource class | identity returned by initialize; instructions are read by the agent |
MCPTool(description) / MCPTool(name, description) | public method | exposes the method as a tool (name defaults to the method name) |
MCPParam(description) / MCPParam(name, description) | parameter | documents and optionally renames the parameter in the JSON Schema (rename it: Delphi convention names like AValue leak otherwise) |
MCPDefault('<JSON literal>') | tool parameter | makes the parameter optional, with that default value |
MCPResource(uri, [name,] description [, mimeType]) | public method | exposes readable content by URI; {param} placeholders make it a template — see references/resources-prompts.md |
MCPPrompt([name,] description) | public method | exposes a reusable prompt template; parameters become the prompt arguments — see references/resources-prompts.md |
RolesAllowed('...') / DenyAll | tool method | per-tool authorization — see references/authorization.md |
MCPOAuth | resource class | 401 + OAuth discovery for unauthenticated requests — see references/authorization.md |
MCPToolUI(uri [, visibility]) | tool method | MCP Apps: links the tool to an interactive ui:// view — see references/mcp-apps.md |
MCPAppResource(uri, [name,] description), MCPAppCSP(...), MCPAppBorder(...) | public method | MCP Apps: the HTML view (text/html;profile=mcp-app) and its CSP/border settings — see references/mcp-apps.md |
MCPMeta('<JSON object>') | tool/resource method | free-form _meta, merged with the MCP Apps attributes |
Tool results: a string becomes a text content block; records (and arrays, numbers...) are serialized with the MARS JSON serializer and records also become structuredContent. Exceptions raised inside a tool are reported as tool execution errors (isError: true), not protocol errors. TDataSet results need TMCPDataResource — see references/database-tools.md.
Parameter/field types map to JSON Schema automatically: strings → string, integers → integer, floats → number, Boolean → boolean, enums → string + enum values, TDateTime → string/date-time, TDate → string/date ("2026-10-19"), dynamic arrays → array, records → nested object. Parameters are listed as required, except those marked [MCPDefault('<JSON literal>')]: they are left out of required, the schema advertises the value as default, and a missing or null argument is bound to it ([MCPDefault('true')], ('7'), ('"value_date"'), ('""'), ('[]') — the literal is converted like any argument).
initialize, versions 2025-06-18, 2025-03-26, 2024-11-05) and modern ones (2026-07-28: no handshake, the version in params._meta["io.modelcontextprotocol/protocolVersion"], server/discover) are served on the same endpoint; the request decides, nothing to configure. Modern results get resultType, ttlMs/cacheScope (lists, discover, resources/read; default 0/private, override GetCacheTTLMs/GetCacheScope in the dispatcher) and the server in _meta. Modern over HTTP: the headers MCP-Protocol-Version, Mcp-Method, Mcp-Name must mirror the body (else 400, -32020); unsupported version: 400, -32022 with data.supported; unknown method: 404; initialize/ping do not exist; resource not found is -32602. Not implemented: subscriptions/listen, multi round-trip requests, tasks.server/discover (modern), initialize (legacy), ping, tools/list, tools/call, resources/list, resources/templates/list, resources/read, prompts/list, prompts/get. Notifications answer 202 with no body; GET/DELETE answer 405 (stateless server, allowed by spec). The resources/prompts capabilities are advertised only when the class declares any. Extend TMCPDispatcher.DispatchRequest for additional methods.GetDispatcherClass on the resource (that is how TMCPDataResource adds dataset support).TMCPStdioServer.Serve(TMyTools.Create, 'name', '1.0.0') in a console program (MARS.MCP.Stdio; JSON-RPC a line each on stdin/stdout, UTF-8; log only to stderr), registered with claude mcp add name -- path\to\exe.references/authorization.md first, it also lists client-specific pitfalls that look like server bugs.references/database-tools.md — dataset ownership rules matter.references/resources-prompts.md.ui:// resources): read references/mcp-apps.md.With curl (initialize / list / call):
curl -X POST http://localhost:8080/rest/default/mcp -H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/list"}'
curl -X POST http://localhost:8080/rest/default/mcp -H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"add_numbers","arguments":{"a":2,"b":3}}}'
With the official MCP Inspector (needs Node.js), which performs a real client handshake:
npx @modelcontextprotocol/inspector --cli http://localhost:8080/rest/default/mcp --transport http --method tools/list
Connect real clients: claude mcp add --transport http my-server http://localhost:8080/rest/default/mcp, or in Open WebUI add an External Tools connection of type MCP (Streamable HTTP) (requires Open WebUI ≥ 0.6.31). Remember: from another machine/container, use the server's LAN IP, not localhost.
| Symptom | Likely cause |
|---|---|
| Client says no tools / "no such tool" | tools not enabled for the chat/model on the client side; or tool hidden by a role filter (by design it answers "Unknown tool") |
"Failed to connect" or a validation error (ttlMs, resultType, cacheScope "Field required") from a recent client (Open WebUI 0.13+, Python mcp SDK 2.x) | the server runs a MARS without the 2026-07-28 revision (2.0.3 or earlier): update MARS |
400 with -32020 Header mismatch | a modern (2026-07-28) request whose MCP-Protocol-Version / Mcp-Method / Mcp-Name headers are missing or differ from the body: hand-made requests (curl) must send them, or use the legacy flow |
| 404 on the endpoint | wrong composed URL — check engine BasePath (/rest), app path, resource [Path] |
| 403 instead of OAuth login | class-level [RolesAllowed] fires before MCP: use [MCPOAuth] for OAuth-protected endpoints (see references/authorization.md) |
| Client aborts during OAuth discovery | a /.well-known/* probe returns 500/garbage — wire TMCPOAuthMetadata.HandleWellKnownRequest in BeforeHandleRequest (it also answers clean 404s and serves the openid-configuration alias) |
| Works with curl, not from Docker/other host | server bound/reached via localhost only — use the LAN IP; verify with curl from the client's network |
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
mcp-server, delphi, mars-curiosity, model-context-protocol, ai-tools
3 skills in this plugin
/mars-developmentDevelop REST APIs with MARS-Curiosity (Delphi REST library) - writing resources (the primary, JAX-RS style model) and, as an additional option, route-based endpoints (Express style, MARS.Core.Routes, middlewares), REST attributes, parameter binding, JWT authentication and roles, dataset publishing with FireDAC or Devart UniDAC/MyDAC/IBDAC, server-sent events (SSE), WebStencils HTML templating, client components, configuration, serialization, code generated from OpenAPI documents or JSON samples (MARSgen). Use this skill whenever the user is working in a Delphi project that uses MARS (units named MARS.*, Server.Ignition, Server.Resources.*, Server.Routes*), asks how to add or modify REST endpoints, secure endpoints with tokens/roles, expose datasets, push events to clients, render server-side HTML, consume a MARS server from a client, handle errors, or configure a MARS server - even if they don't mention MARS by name but the code clearly uses it./mars-new-projectScaffold a new REST server project with MARS-Curiosity (Delphi REST library). Use this skill whenever the user wants to create, bootstrap, or set up a new MARS server, a new Delphi REST API/server/microservice/web service based on MARS, or asks "how do I start a MARS project". Also use it when the user has an OpenAPI (Swagger 3) document to implement as a MARS server, and when adding a new host flavor or deploying a MARS server (console, VCL/FMX GUI, Windows service, ISAPI on IIS, Apache module, FastCGI, Linux daemon, HTTPS/SSL setup).npx claudepluginhub andrea-magni/mars --plugin mars-curiosityOther plugins' skills for the same job