MCP Server
在 Delphi 中构建 Model Context Protocol (MCP) 服务器。向 AI 应用程序暴露工具、资源和提示词。
在 Delphi 中构建 Model Context Protocol (MCP) 服务器。向 AI 应用程序暴露工具、资源和提示词。
将自定义工具、提示词和资源暴露给任意支持 MCP 的 LLM 客户端。基于 sgcWebSockets HTTP 服务器托管带有 HTTP 和 HTTP Streamable 传输的 JSON-RPC 端点。
TsgcWSAPIServer_MCP
Model Context Protocol server
Windows, macOS, Linux, iOS, Android
Enterprise(AI 附加模块)
附加到 HTTP 服务器,填写 ServerInfo,挂接 OnMCPRequest* 处理程序,设置 Active := True。
uses
sgcAI_MCP_Server, sgcAI_MCP_Classes;
var
MCP: TsgcWSAPIServer_MCP;
begin
MCP := TsgcWSAPIServer_MCP.Create(nil);
MCP.MCPOptions.HttpOptions.Port := 8080;
MCP.MCPOptions.ServerInfo.Name := 'sgc-mcp-server';
MCP.MCPOptions.ServerInfo.Title := 'Weather MCP';
MCP.MCPOptions.ServerInfo.Version := '1.0.0';
// Lifecycle + incoming request handlers
MCP.OnMCPInitialize := SrvInitialize;
MCP.OnMCPSessionNew := SrvSessionNew;
MCP.OnMCPRequestTool := SrvCallTool;
MCP.OnMCPRequestPrompt := SrvGetPrompt;
MCP.OnMCPRequestResource := SrvReadResource;
MCP.Active := True;
// Push a notification to every connected session
MCP.SendNotificationToolsListChanged;
end;
5 个发布属性、9 个方法、12 个事件 — 来自组件参考。
Methods: KeepAlive.
Events: OnMCPHTTPRequest, OnMCPHTTPResponse.
Published properties: MCPOptions, EndpointOptions, TransportOptions.
Published properties: Version.
Properties: Server.
Methods: RequestRootsList, RequestSamplingCreateMessage, RequestElicitationCreate.
本组件所实现协议的权威参考来源。