Files
OllaHub/lib/types/mcp-chat.ts
Evandro Fonseca Junior 4739a13458 feat(api): integrate MCP tools support in Ollama chat route
Add support for Model Context Protocol (MCP) tools in the Ollama chat API. Detect model capabilities to use native tools or prompt engineering. Handle tool calls, execute them via MCPExecutor, and inject results back into the conversation for seamless tool-assisted responses. This enhances chat functionality by enabling external tool integration.
2025-10-28 22:50:03 -03:00

75 lines
1.4 KiB
TypeScript

/**
* Tipos e interfaces para integração de MCPs no chat
*/
/**
* Representa um tool MCP com schema JSON
*/
export interface MCPTool {
name: string;
description: string;
inputSchema: {
type: "object";
properties: Record<string, any>;
required?: string[];
};
}
/**
* Contexto de MCPs ativos para a conversa
*/
export interface MCPChatContext {
mcpId: string;
enabled: boolean;
tools: MCPTool[];
config: any;
}
/**
* Resultado da execução de um MCP
*/
export interface MCPExecutionResult {
success: boolean;
toolName: string;
mcpId: string;
result?: any;
error?: string;
executionTime?: number;
}
/**
* Capabilities de function calling do modelo
*/
export interface ModelCapabilities {
supportsNativeTools: boolean;
requiresPromptEngineering: boolean;
modelName: string;
toolCallFormat?: "openai" | "anthropic" | "custom";
}
/**
* Configuração de MCPs para chat
*/
export interface MCPChatConfig {
alwaysActive: string[]; // MCPs sempre ativos
neverUse: string[]; // MCPs nunca usar
activationMode: "automatic" | "keywords" | "manual";
}
/**
* Intent detectado na mensagem do usuário
*/
export interface DetectedIntent {
type:
| "web_search"
| "time"
| "weather"
| "file"
| "code"
| "database"
| "other";
confidence: number;
keywords: string[];
suggestedTools: string[];
}