diff --git a/Foundation.Data.Doublets.Cli/Foundation.Data.Doublets.Cli.csproj b/Foundation.Data.Doublets.Cli/Foundation.Data.Doublets.Cli.csproj
index 1d8f9ab..ebb738f 100644
--- a/Foundation.Data.Doublets.Cli/Foundation.Data.Doublets.Cli.csproj
+++ b/Foundation.Data.Doublets.Cli/Foundation.Data.Doublets.Cli.csproj
@@ -26,6 +26,8 @@
+
+
diff --git a/Foundation.Data.Doublets.Cli/McpModels.cs b/Foundation.Data.Doublets.Cli/McpModels.cs
new file mode 100644
index 0000000..4e553cd
--- /dev/null
+++ b/Foundation.Data.Doublets.Cli/McpModels.cs
@@ -0,0 +1,248 @@
+using System.Text.Json.Serialization;
+
+namespace Foundation.Data.Doublets.Cli
+{
+ // Initialize request/response
+ public class McpInitializeParams
+ {
+ [JsonPropertyName("protocolVersion")]
+ public string ProtocolVersion { get; set; } = "";
+
+ [JsonPropertyName("capabilities")]
+ public McpClientCapabilities? Capabilities { get; set; }
+
+ [JsonPropertyName("clientInfo")]
+ public McpClientInfo? ClientInfo { get; set; }
+ }
+
+ public class McpInitializeResult
+ {
+ [JsonPropertyName("protocolVersion")]
+ public string ProtocolVersion { get; set; } = "";
+
+ [JsonPropertyName("serverInfo")]
+ public McpServerInfo? ServerInfo { get; set; }
+
+ [JsonPropertyName("capabilities")]
+ public McpServerCapabilities? Capabilities { get; set; }
+ }
+
+ public class McpClientInfo
+ {
+ [JsonPropertyName("name")]
+ public string? Name { get; set; }
+
+ [JsonPropertyName("version")]
+ public string? Version { get; set; }
+ }
+
+ public class McpServerInfo
+ {
+ [JsonPropertyName("name")]
+ public string? Name { get; set; }
+
+ [JsonPropertyName("version")]
+ public string? Version { get; set; }
+ }
+
+ public class McpClientCapabilities
+ {
+ [JsonPropertyName("experimental")]
+ public object? Experimental { get; set; }
+
+ [JsonPropertyName("sampling")]
+ public object? Sampling { get; set; }
+ }
+
+ public class McpServerCapabilities
+ {
+ [JsonPropertyName("experimental")]
+ public object? Experimental { get; set; }
+
+ [JsonPropertyName("logging")]
+ public object? Logging { get; set; }
+
+ [JsonPropertyName("prompts")]
+ public McpPromptsCapability? Prompts { get; set; }
+
+ [JsonPropertyName("resources")]
+ public McpResourcesCapability? Resources { get; set; }
+
+ [JsonPropertyName("tools")]
+ public McpToolsCapability? Tools { get; set; }
+ }
+
+ public class McpPromptsCapability
+ {
+ [JsonPropertyName("listChanged")]
+ public bool ListChanged { get; set; }
+ }
+
+ public class McpResourcesCapability
+ {
+ [JsonPropertyName("subscribe")]
+ public bool Subscribe { get; set; }
+
+ [JsonPropertyName("listChanged")]
+ public bool ListChanged { get; set; }
+ }
+
+ public class McpToolsCapability
+ {
+ [JsonPropertyName("listChanged")]
+ public bool ListChanged { get; set; }
+ }
+
+ // Resources
+ public class McpResourcesListResult
+ {
+ [JsonPropertyName("resources")]
+ public McpResource[]? Resources { get; set; }
+ }
+
+ public class McpResource
+ {
+ [JsonPropertyName("uri")]
+ public string Uri { get; set; } = "";
+
+ [JsonPropertyName("name")]
+ public string Name { get; set; } = "";
+
+ [JsonPropertyName("description")]
+ public string? Description { get; set; }
+
+ [JsonPropertyName("mimeType")]
+ public string? MimeType { get; set; }
+ }
+
+ public class McpResourcesReadParams
+ {
+ [JsonPropertyName("uri")]
+ public string Uri { get; set; } = "";
+ }
+
+ public class McpResourcesReadResult
+ {
+ [JsonPropertyName("contents")]
+ public McpResourceContent[]? Contents { get; set; }
+ }
+
+ public class McpResourceContent
+ {
+ [JsonPropertyName("uri")]
+ public string Uri { get; set; } = "";
+
+ [JsonPropertyName("mimeType")]
+ public string? MimeType { get; set; }
+
+ [JsonPropertyName("text")]
+ public string? Text { get; set; }
+
+ [JsonPropertyName("blob")]
+ public byte[]? Blob { get; set; }
+ }
+
+ // Tools
+ public class McpToolsListResult
+ {
+ [JsonPropertyName("tools")]
+ public McpTool[]? Tools { get; set; }
+ }
+
+ public class McpTool
+ {
+ [JsonPropertyName("name")]
+ public string Name { get; set; } = "";
+
+ [JsonPropertyName("description")]
+ public string? Description { get; set; }
+
+ [JsonPropertyName("inputSchema")]
+ public object? InputSchema { get; set; }
+ }
+
+ public class McpToolsCallParams
+ {
+ [JsonPropertyName("name")]
+ public string Name { get; set; } = "";
+
+ [JsonPropertyName("arguments")]
+ public System.Text.Json.JsonElement Arguments { get; set; }
+ }
+
+ public class McpToolsCallResult
+ {
+ [JsonPropertyName("content")]
+ public McpContent[]? Content { get; set; }
+
+ [JsonPropertyName("isError")]
+ public bool IsError { get; set; }
+ }
+
+ public class McpContent
+ {
+ [JsonPropertyName("type")]
+ public string Type { get; set; } = "";
+
+ [JsonPropertyName("text")]
+ public string? Text { get; set; }
+ }
+
+ // Prompts
+ public class McpPromptsListResult
+ {
+ [JsonPropertyName("prompts")]
+ public McpPrompt[]? Prompts { get; set; }
+ }
+
+ public class McpPrompt
+ {
+ [JsonPropertyName("name")]
+ public string Name { get; set; } = "";
+
+ [JsonPropertyName("description")]
+ public string? Description { get; set; }
+
+ [JsonPropertyName("arguments")]
+ public McpPromptArgument[]? Arguments { get; set; }
+ }
+
+ public class McpPromptArgument
+ {
+ [JsonPropertyName("name")]
+ public string Name { get; set; } = "";
+
+ [JsonPropertyName("description")]
+ public string? Description { get; set; }
+
+ [JsonPropertyName("required")]
+ public bool Required { get; set; }
+ }
+
+ public class McpPromptsGetParams
+ {
+ [JsonPropertyName("name")]
+ public string Name { get; set; } = "";
+
+ [JsonPropertyName("arguments")]
+ public Dictionary? Arguments { get; set; }
+ }
+
+ public class McpPromptsGetResult
+ {
+ [JsonPropertyName("description")]
+ public string? Description { get; set; }
+
+ [JsonPropertyName("messages")]
+ public McpPromptMessage[]? Messages { get; set; }
+ }
+
+ public class McpPromptMessage
+ {
+ [JsonPropertyName("role")]
+ public string Role { get; set; } = "";
+
+ [JsonPropertyName("content")]
+ public McpContent? Content { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/Foundation.Data.Doublets.Cli/McpServer.cs b/Foundation.Data.Doublets.Cli/McpServer.cs
new file mode 100644
index 0000000..3a02a7f
--- /dev/null
+++ b/Foundation.Data.Doublets.Cli/McpServer.cs
@@ -0,0 +1,575 @@
+using System.Text.Json;
+using System.Text.Json.Serialization;
+using StreamJsonRpc;
+using Platform.Data.Doublets;
+using Platform.Data;
+using DoubletLink = Platform.Data.Doublets.Link;
+
+namespace Foundation.Data.Doublets.Cli
+{
+ public class McpServer
+ {
+ private readonly NamedLinksDecorator _links;
+ private readonly bool _tracingEnabled;
+
+ public McpServer(NamedLinksDecorator links, bool tracingEnabled = false)
+ {
+ _links = links;
+ _tracingEnabled = tracingEnabled;
+ }
+
+ // MCP Initialization
+ [JsonRpcMethod("initialize")]
+ public McpInitializeResult Initialize(McpInitializeParams parameters)
+ {
+ if (_tracingEnabled)
+ Console.WriteLine($"[MCP] Initialize called with clientInfo: {parameters.ClientInfo?.Name}");
+
+ return new McpInitializeResult
+ {
+ ProtocolVersion = "2024-11-05",
+ ServerInfo = new McpServerInfo
+ {
+ Name = "link-cli-mcp",
+ Version = "1.0.0"
+ },
+ Capabilities = new McpServerCapabilities
+ {
+ Resources = new McpResourcesCapability
+ {
+ Subscribe = false,
+ ListChanged = false
+ },
+ Tools = new McpToolsCapability
+ {
+ ListChanged = false
+ },
+ Prompts = new McpPromptsCapability
+ {
+ ListChanged = false
+ }
+ }
+ };
+ }
+
+ // Resources: Expose links data for reading
+ [JsonRpcMethod("resources/list")]
+ public McpResourcesListResult ListResources()
+ {
+ if (_tracingEnabled)
+ Console.WriteLine("[MCP] resources/list called");
+
+ return new McpResourcesListResult
+ {
+ Resources = new[]
+ {
+ new McpResource
+ {
+ Uri = "memory://links/all",
+ Name = "All Memory Links",
+ Description = "All links stored in the neural network memory",
+ MimeType = "application/json"
+ },
+ new McpResource
+ {
+ Uri = "memory://links/search",
+ Name = "Search Memory Links",
+ Description = "Search links by pattern or content",
+ MimeType = "application/json"
+ }
+ }
+ };
+ }
+
+ [JsonRpcMethod("resources/read")]
+ public McpResourcesReadResult ReadResource(McpResourcesReadParams parameters)
+ {
+ if (_tracingEnabled)
+ Console.WriteLine($"[MCP] resources/read called for: {parameters.Uri}");
+
+ return parameters.Uri switch
+ {
+ "memory://links/all" => ReadAllLinks(),
+ "memory://links/search" => ReadSearchableLinks(),
+ _ => throw new InvalidOperationException($"Unknown resource: {parameters.Uri}")
+ };
+ }
+
+ private McpResourcesReadResult ReadAllLinks()
+ {
+ var linksList = new List