MCP Overview
Model Context Protocol integration — expose or consume MCP-compatible tools.
What is MCP?
The Model Context Protocol (MCP) is an open standard for connecting AI models to tools and data sources. AgentForge supports both sides:
- MCP Client — connect to external MCP servers and use their tools
- MCP Server — expose AgentForge tools as MCP-compatible endpoints
Quick Start
As Client (consume MCP tools)
import { MCPClient } from '@ahzan-agentforge/core';
const client = new MCPClient({
command: 'npx',
args: ['@modelcontextprotocol/server-filesystem', '/path/to/dir'],
});
await client.connect();
const tools = await client.listTools();As Server (expose tools)
import { MCPServer } from '@ahzan-agentforge/core';
const server = new MCPServer({
name: 'my-agent-tools',
version: '1.0.0',
tools: [myTool1, myTool2],
});
await server.start();Tool Adapters
Convert between AgentForge tools and MCP tools:
import { fromMCPTool, toMCPTool } from '@ahzan-agentforge/core';
// MCP tool → AgentForge tool
const agentTool = fromMCPTool(mcpToolDefinition);
// AgentForge tool → MCP tool definition
const mcpTool = toMCPTool(agentForgeTool);