andrea-magni/mars/mars-mcp-server
Claude Code and agent skill by andrea-magni/mars
- community
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-serverSKILL.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
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
| 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).
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 answer202with no body;GET/DELETEanswer405(stateless server, allowed by spec). Theresources/promptscapabilities are advertised only when the class declares any. ExtendTMCPDispatcher.DispatchRequestfor 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
GetDispatcherClasson the resource (that is howTMCPDataResourceadds 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 withclaude 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.mdfirst, 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): readreferences/mcp-apps.md.
Verify the server
With curl (initialize / list / call):
With the official MCP Inspector (needs Node.js), which performs a real client handshake:
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
| 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") | |
| 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 |
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
- SKILL.md in the repositoryCheckingSkills/mars-mcp-server/SKILL.md
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
[](https://verified-skill.com/skills/andrea-magni/mars/mars-mcp-server)