andrea-magni/mars/mars-mcp-server

Claude Code and agent skill by andrea-magni/mars

Trust tier 2
  • community
LLM review pending
Source check pending

Checking that the SKILL.md file is still in the repository.

Build MCP (Model Context Protocol) servers in Delphi with MARS-Curiosity, so AI agents (Claude, ChatGPT, Open WebUI/Ollama, MCP Inspector) can discover and call Delphi code as tools, read MCP resources, use MCP prompts and show interactive views (MCP Apps). Use this skill whenever the user wants to expose Delphi/MARS functionality to an AI agent or LLM, mentions MCP, MCP server, MCP tools, resources, prompts, tool calling, function calling, AI agents, connectors, or wants Claude/ChatGPT/a local model to query their Delphi application or database; also when working with MARS.MCP.* units, TMCPResource, [MCPTool], [MCPResource], [MCPPrompt], [MCPToolUI], [MCPAppResource], TMCPOAuthServer, MCP Apps / interactive UIs rendered by Claude next to a tool result, or debugging an MCP client that cannot connect or authenticate to a MARS server.

Install

npx vskill@latest install andrea-magni/mars/mars-mcp-server

SKILL.md

Build an MCP server with MARS-Curiosity

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.

Minimal MCP server

pascal
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.

What the attributes do

AttributeWhereEffect
MCPServerInfo(name, version, instructions)resource classidentity returned by initialize; instructions are read by the agent
MCPTool(description) / MCPTool(name, description)public methodexposes the method as a tool (name defaults to the method name)
MCPParam(description) / MCPParam(name, description)parameterdocuments and optionally renames the parameter in the JSON Schema (rename it: Delphi convention names like AValue leak otherwise)
MCPDefault('<JSON literal>')tool parametermakes the parameter optional, with that default value
MCPResource(uri, [name,] description [, mimeType])public methodexposes readable content by URI; {param} placeholders make it a template — see references/resources-prompts.md
MCPPrompt([name,] description)public methodexposes a reusable prompt template; parameters become the prompt arguments — see references/resources-prompts.md
RolesAllowed('...') / DenyAlltool methodper-tool authorization — see references/authorization.md
MCPOAuthresource class401 + OAuth discovery for unauthenticated requests — see references/authorization.md
MCPToolUI(uri [, visibility])tool methodMCP Apps: links the tool to an interactive ui:// view — see references/mcp-apps.md
MCPAppResource(uri, [name,] description), MCPAppCSP(...), MCPAppBorder(...)public methodMCP Apps: the HTML view (text/html;profile=mcp-app) and its CSP/border settings — see references/mcp-apps.md
MCPMeta('<JSON object>')tool/resource methodfree-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).

Protocol facts worth knowing

  • Supported JSON-RPC methods: initialize (protocol versions 2025-06-18, 2025-03-26, 2024-11-05), 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.
  • Tool discovery is cached per resource class (thread-safe, RTTI scanned once). The authorization filter is evaluated per request, so caching never leaks role-protected tools.
  • The dispatcher class is pluggable: override GetDispatcherClass on the resource (that is how TMCPDataResource adds dataset support).
  • A local server on stdio, without HTTP: 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.

When to read the references

  • Any authentication requirement — Bearer tokens, roles, hiding tools per user, OAuth login window for Claude/ChatGPT/Open WebUI: read references/authorization.md first, it also lists client-specific pitfalls that look like server bugs.
  • Tools that query a database (FireDAC, TFDQuery, TMARSFireDAC, or Devart UniDAC/MyDAC/IBDAC with TMARSUniDAC/TMARSMyDAC/TMARSIBDAC): read references/database-tools.md — dataset ownership rules matter.
  • MCP resources or prompts (attachable content like DB schemas, URI templates, reusable prompt templates): read references/resources-prompts.md.
  • Interactive UIs / MCP Apps (a chart, form or dashboard rendered by Claude or another host next to a tool result, ui:// resources): read references/mcp-apps.md.

Verify the server

With curl (initialize / list / call):

bash
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:

bash
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.

Troubleshooting quick table

SymptomLikely 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")
404 on the endpointwrong composed URL — check engine BasePath (/rest), app path, resource [Path]
403 instead of OAuth loginclass-level [RolesAllowed] fires before MCP: use [MCPOAuth] for OAuth-protected endpoints (see references/authorization.md)
Client aborts during OAuth discoverya /.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 hostserver bound/reached via localhost only — use the LAN IP; verify with curl from the client's network

Security

  • Security scanPassed, 100 of 100Pattern checks on the skill's files.
  • Model reviewNot runA model review is scheduled for the next rescan.

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

Repository stars
393
Repository forks
115
7-day trend score
30

Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 31 Aug 2026, 2 months ago.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/andrea-magni/mars/mars-mcp-server/badge)](https://verified-skill.com/skills/andrea-magni/mars/mars-mcp-server)

Something wrong with this skill or its page? Tell us.