FabrCore MCP (Model Context Protocol) integration — configure MCP servers for agents, Stdio and HTTP transport, config-driven vs code-driven setup, tool resolution, and troubleshooting. Triggers on: "MCP", "Model Context Protocol", "McpServerConfig", "ConnectMcpServerAsync", "MCP tools", "stdio MCP", "HTTP MCP", "MCP server", "McpTransportType", "MCP integration", "external tools MCP". Do NOT use for: plugins or standalone tools — use fabrcore-plugins-tools. Do NOT use for: general agent development — use fabrcore-agent.
FabrCore natively supports the Model Context Protocol (MCP) for connecting agents to external tool servers. MCP tools are resolved alongside plugin and standalone tools and presented to the LLM automatically.
public class McpServerConfig
{
public string Name { get; set; } // Unique server name
public McpTransportType TransportType { get; set; } // Stdio or Http
// Stdio transport
public string Command { get; set; } // Executable path
public List<string> Arguments { get; set; } // Command arguments
public Dictionary<string, string> Env { get; set; } // Environment variables
// Http transport
public string Url { get; set; } // Server endpoint URL
public Dictionary<string, string> Headers { get; set; } // HTTP headers
}
public enum McpTransportType { Stdio, Http }
Add MCP server configurations to AgentConfiguration.McpServers:
For local MCP servers that communicate via stdin/stdout:
{
"McpServers": [
{
"Name": "filesystem",
"TransportType": "Stdio",
"Command": "npx",
"Arguments": ["-y", "@anthropic/mcp-filesystem", "/data"],
"Env": { "NODE_ENV": "production" }
}
]
}
For remote MCP servers accessible via HTTP:
{
"McpServers": [
{
"Name": "remote-api",
"TransportType": "Http",
"Url": "https://api.example.com/mcp",
"Headers": {
"Authorization": "Bearer your-token"
}
}
]
}
When an agent initializes via ResolveConfiguredToolsAsync():
config.McpServersIMcpClient connection for each serverListToolsAsync() to discover available toolsAITool instancesChatOptions.ToolsThe MCP client lifecycle is managed by FabrCoreAgentProxy:
OnInitialize()MCP servers listed in AgentConfiguration.McpServers are automatically connected by ResolveConfiguredToolsAsync(). This is fail-open — if an MCP server can't connect, the agent continues without those tools:
var tools = await ResolveConfiguredToolsAsync();
// Includes MCP tools if connections succeeded
For programmatic control where exceptions propagate (you handle errors):
var mcpTools = await ConnectMcpServerAsync(new McpServerConfig
{
Name = "my-mcp-server",
TransportType = McpTransportType.Stdio,
Command = "npx",
Arguments = ["-y", "@my-org/mcp-server"],
Env = new() { ["API_KEY"] = "secret" }
});
tools.AddRange(mcpTools);
HTTP MCP server:
var mcpTools = await ConnectMcpServerAsync(new McpServerConfig
{
Name = "remote-tools",
TransportType = McpTransportType.Http,
Url = "https://tools.example.com/mcp",
Headers = new() { ["Authorization"] = "Bearer token" }
});
MCP tools coexist with plugin and standalone tools:
{
"Handle": "research-agent",
"AgentType": "researcher",
"Plugins": ["web-browser"],
"Tools": ["format-json"],
"McpServers": [
{
"Name": "search-api",
"TransportType": "Http",
"Url": "https://search.example.com/mcp"
}
]
}
The LLM sees all tools from all sources and can use any of them.
{
"Name": "filesystem",
"TransportType": "Stdio",
"Command": "npx",
"Arguments": ["-y", "@anthropic/mcp-filesystem", "/allowed/path"]
}
{
"Name": "git",
"TransportType": "Stdio",
"Command": "npx",
"Arguments": ["-y", "@anthropic/mcp-git"]
}
{
"Name": "postgres",
"TransportType": "Stdio",
"Command": "npx",
"Arguments": ["-y", "@anthropic/mcp-postgres"],
"Env": { "DATABASE_URL": "postgresql://user:pass@localhost/db" }
}
var config = new AgentConfiguration
{
Handle = "my-agent",
AgentType = "my-agent",
McpServers =
[
new McpServerConfig
{
Name = "filesystem",
TransportType = McpTransportType.Stdio,
Command = "npx",
Arguments = ["-y", "@anthropic/mcp-filesystem", "/data"]
},
new McpServerConfig
{
Name = "api",
TransportType = McpTransportType.Http,
Url = "https://api.example.com/mcp",
Headers = new() { ["Authorization"] = "Bearer token" }
}
]
};
Connection refused:
Tools not appearing:
ListToolsAsync correctlyName doesn't conflict with other MCP serversTool invocation errors:
Performance: