Research conducted on modern AI coding assistants (Cursor, GitHub Copilot, Cline,
Aider, Windsurf, Replit Agent) to understand architecture patterns, context management,
code editing workflows, and tool use protocols.
Key Decision: Pivoted from building full CLI (40-50h) to validation-driven MCP-first
approach (10-15h). Build 5 core CODEX MCP tools that work with ANY coding assistant,
validate adoption over 2-4 weeks, then decide on full CLI if demand proven.
Files:
- research/ai-systems/modern-coding-assistants-architecture.md (comprehensive research)
- research/ai-systems/codex-coding-assistant-implementation-plan.md (original CLI plan, preserved)
- research/ai-systems/codex-mcp-tools-implementation-plan.md (approved MCP-first plan)
- ideas/registry.json (updated with approved MCP tools proposal)
Architech Validation: APPROVED with pivot to MCP-first approach
Human Decision: Approved (pragmatic validation-driven development)
Next: Begin Phase 1 implementation (10-15 hours, 5 core MCP tools)
🤖 Generated with CODEX Research System
Co-Authored-By: The Archivist <archivist@codex.svrnty.io>
Co-Authored-By: The Architech <architech@codex.svrnty.io>
Co-Authored-By: Mathias Beaulieu-Duncan <mat@svrnty.io>
125 lines
3.6 KiB
C#
125 lines
3.6 KiB
C#
using OpenHarbor.MCP.Client.Core.Exceptions;
|
|
using OpenHarbor.MCP.Client.Core.Models;
|
|
using OpenHarbor.MCP.Client.Infrastructure;
|
|
|
|
Console.WriteLine("=== OpenHarbor.MCP.Client - CODEX Example ===\n");
|
|
|
|
// Step 1: Configure MCP servers
|
|
var serverConfigs = new List<McpServerConfig>
|
|
{
|
|
new McpServerConfig
|
|
{
|
|
Name = "codex-server",
|
|
Transport = new StdioTransportConfig
|
|
{
|
|
Type = "Stdio",
|
|
Command = "dotnet",
|
|
Args = new[] { "run", "--project", "/home/svrnty/codex/OpenHarbor.MCP.Server/samples/CodexMcpServer/CodexMcpServer.csproj" }
|
|
},
|
|
Timeout = TimeSpan.FromSeconds(30),
|
|
Enabled = true
|
|
}
|
|
};
|
|
|
|
// Step 2: Create and initialize the MCP client
|
|
await using var mcpClient = new McpClient(serverConfigs);
|
|
|
|
try
|
|
{
|
|
Console.WriteLine("Connecting to MCP servers...");
|
|
await mcpClient.ConnectAllAsync();
|
|
|
|
var connectedServers = await mcpClient.GetConnectedServersAsync();
|
|
Console.WriteLine($"✓ Connected to {connectedServers.Count()} server(s)\n");
|
|
|
|
// Step 3: List available tools from each server
|
|
foreach (var server in connectedServers)
|
|
{
|
|
Console.WriteLine($"--- Tools from '{server.Name}' ---");
|
|
|
|
try
|
|
{
|
|
var tools = await mcpClient.ListToolsAsync(server.Name);
|
|
|
|
foreach (var tool in tools)
|
|
{
|
|
Console.WriteLine($" • {tool.Name}");
|
|
Console.WriteLine($" Description: {tool.Description}");
|
|
}
|
|
|
|
Console.WriteLine();
|
|
}
|
|
catch (McpConnectionException ex)
|
|
{
|
|
Console.WriteLine($" Error listing tools: {ex.Message}\n");
|
|
}
|
|
}
|
|
|
|
// Step 4: Example - Search CODEX (if tool exists)
|
|
Console.WriteLine("--- Example: Searching CODEX ---");
|
|
|
|
try
|
|
{
|
|
var searchResult = await mcpClient.CallToolAsync(
|
|
serverName: "codex-server",
|
|
toolName: "search_codex",
|
|
arguments: new Dictionary<string, object>
|
|
{
|
|
["query"] = "Model Context Protocol",
|
|
["maxResults"] = 5
|
|
}
|
|
);
|
|
|
|
if (searchResult.IsSuccess)
|
|
{
|
|
Console.WriteLine("✓ Search successful!");
|
|
Console.WriteLine($"Results:\n{searchResult.Content}");
|
|
}
|
|
else
|
|
{
|
|
Console.WriteLine($"✗ Search failed: {searchResult.Error}");
|
|
}
|
|
}
|
|
catch (ServerNotFoundException ex)
|
|
{
|
|
Console.WriteLine($"✗ Server not found: {ex.Message}");
|
|
}
|
|
catch (ToolNotFoundException ex)
|
|
{
|
|
Console.WriteLine($"✗ Tool not found: {ex.Message}");
|
|
}
|
|
catch (McpConnectionException ex)
|
|
{
|
|
Console.WriteLine($"✗ Connection error: {ex.Message}");
|
|
}
|
|
|
|
Console.WriteLine("\n--- Example: Health Check ---");
|
|
|
|
// Step 5: Health check example
|
|
foreach (var server in connectedServers)
|
|
{
|
|
try
|
|
{
|
|
await mcpClient.PingAsync(server.Name);
|
|
Console.WriteLine($"✓ {server.Name} is healthy");
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Console.WriteLine($"✗ {server.Name} is unhealthy: {ex.Message}");
|
|
}
|
|
}
|
|
|
|
Console.WriteLine("\nDisconnecting from all servers...");
|
|
await mcpClient.DisconnectAllAsync();
|
|
Console.WriteLine("✓ Disconnected successfully");
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Console.WriteLine($"\n✗ Error: {ex.Message}");
|
|
Console.WriteLine($"Stack trace: {ex.StackTrace}");
|
|
return 1;
|
|
}
|
|
|
|
Console.WriteLine("\n=== Example Complete ===");
|
|
return 0;
|