
janwielemaker/mcp
Developer toolsこのページは AI により自動翻訳されています。技術的な詳細は原文をご確認ください。 原文を見る
SWI-Prolog MCP server framework with Prolog manual, introspection and toplevel servers.
概要
This pack provides a framework for writing Model Context Protocol servers in SWI-Prolog, plus a set of ready-made server modules that an LLM coding assistant can use to introspect Prolog code, drive a real SWI toplevel as a "target", and read source / git history from configured directories. The framework rides on top of library(json_rpc_server) and library(json_schema) that ship with SWI-Prolog. Per-tool argument validation against the supplied JSON Schema is handled by the JSON Schema layer. Experimental. Implements the revision of the MCP specification. - — library(mcp/stdio); newline-delimited JSON-RPC over stdin/stdout, the form used by the official mcp CLI and by Claude Code's local-server configuration. - — library(mcp/http); long-lived SSE stream for server-initiated notifications plus POSTs for client requests. Sessions are keyed by the Mcp-Session-Id HTTP header. Intended for hosting on www.swi-prolog.org (behind a reverse proxy handling TLS and auth).
README
以下は原文 README の抜粋です。原文を見る。
MCP — Model Context Protocol server framework for SWI-Prolog
This pack provides a framework for writing Model Context Protocol servers in SWI-Prolog, plus a set of ready-made server modules that an LLM coding assistant can use to introspect Prolog code, drive a real SWI toplevel as a “target”, and read source / git history from configured directories.
The framework rides on top of library(json_rpc_server) and
library(json_schema) that ship with SWI-Prolog. Per-tool argument
validation against the supplied JSON Schema is handled by the JSON
Schema layer.
Status
Experimental. Implements the 2024-11-05 revision of the MCP specification.
Transports:
- stdio —
library(mcp/stdio); newline-delimited JSON-RPC over stdin/stdout, the form used by the officialmcpCLI and by Claude Code’s local-server configuration. - HTTP + SSE —
library(mcp/http); long-lived SSE stream for server-initiated notifications plus POSTs for client requests. Sessions are keyed by theMcp-Session-IdHTTP header. Intended for hosting onwww.swi-prolog.org(behind a reverse proxy handling TLS and auth).
MCP capabilities
- Tools (
tools/list,tools/call,notifications/tools/list_changed) - Resources (
resources/list,resources/read,resources/templates/list) - Prompts (
prompts/list,prompts/get)
Progress notifications (notifications/progress and the
params._meta.progressToken intake on requests) are not implemented.
Tool calls reply with a single buffered JSON-RPC response; there is no
intra-call streaming. On the HTTP transport the mcp_notify/2 path
reaches only clients holding a GET /sse stream — the streamable-HTTP
POST /mcp reply is sent as application/json, not as an SSE event
stream, so a tool cannot interleave progress events into its own
response.
Writing a server
A minimal hello server:
:- module(hello_server, []).
:- use_module(library(mcp/server)).
:- use_module(library(mcp/stdio)).
:- mcp_server_info(#{name:"hello", version:"0.1.0"}).
:- mcp_tool(echo,
"Echo the input message",
#{ properties: #{ msg: #{type: string} },
required: [msg]
}).
echo(#{msg: M}, M).
:- initialization(mcp_stdio_run, main).
Run it as swipl hello_server.pl. The server speaks MCP on
stdin/stdout.
mcp_tool/3 is the only registration primitive: a name, a one-line
description shown to the LLM, and a JSON Schema for the arguments.
The matching Prolog predicate is Name(+Args, -Result), where Args
is the validated input dict and Result is either a string (auto-
wrapped as a text content item), a dict (a single content item) or a
list of content items.
Included server modules
Each of these is :- use_module/1-able as
library(mcp/servers/). They all register their tools through
the same multifile tool/4 predicate, so a single server can compose
インストール
This server does not publish a one-line install command.
Open the repository installation guide MCP 初心者?mcpskill.org のガイドから始めましょう →