agent-file
Version:
Self-contained HTML agent format with built-in security
122 lines • 2.94 kB
TypeScript
/**
* MCP Client for Browser Environments
* Implements Streamable HTTP transport for Model Context Protocol
*/
export interface MCPTool {
name: string;
description?: string;
inputSchema: {
type: string;
properties?: Record<string, any>;
required?: string[];
};
}
export interface MCPResource {
uri: string;
name: string;
description?: string;
mimeType?: string;
}
export interface MCPServerInfo {
name: string;
version: string;
protocolVersion: string;
capabilities: {
tools?: Record<string, any>;
resources?: Record<string, any>;
prompts?: Record<string, any>;
};
}
export interface MCPCallToolResult {
content: Array<{
type: 'text' | 'image' | 'resource';
text?: string;
data?: string;
mimeType?: string;
}>;
isError?: boolean;
}
export declare class MCPClient {
private url;
private sessionId;
private serverInfo;
private tools;
private resources;
private requestId;
private authToken?;
constructor(url: string, authToken?: string);
/**
* Initialize connection to MCP server
*/
connect(): Promise<void>;
/**
* Discover available tools from the server
*/
private discoverTools;
/**
* Discover available resources from the server
*/
private discoverResources;
/**
* Get list of available tools
*/
getTools(): MCPTool[];
/**
* Get list of available resources
*/
getResources(): MCPResource[];
/**
* Get server information
*/
getServerInfo(): MCPServerInfo | null;
/**
* Call a tool on the MCP server
*/
callTool(name: string, args?: Record<string, any>): Promise<MCPCallToolResult>;
/**
* Read a resource from the MCP server
*/
readResource(uri: string): Promise<any>;
/**
* Send a JSON-RPC request to the MCP server
*/
private request;
/**
* Send a JSON-RPC notification (no response expected)
*/
private notify;
/**
* Disconnect from the MCP server
*/
disconnect(): Promise<void>;
}
/**
* MCP Manager - manages multiple MCP server connections
*/
export declare class MCPManager {
private clients;
/**
* Add an MCP server connection
*/
addServer(name: string, url: string, authToken?: string): Promise<void>;
/**
* Get an MCP client by name
*/
getClient(name: string): MCPClient | undefined;
/**
* Get all available tools from all servers
*/
getAllTools(): Array<{
server: string;
tool: MCPTool;
}>;
/**
* Call a tool by name (searches all servers)
*/
callTool(toolName: string, args?: Record<string, any>): Promise<MCPCallToolResult>;
/**
* Disconnect all servers
*/
disconnectAll(): Promise<void>;
}
//# sourceMappingURL=mcp-client.d.ts.map