Skip to main content
Glama

kobold_chat

Enable chat completion through OpenAI-compatible API integration, allowing dynamic text generation and conversation handling with customizable parameters for temperature, max tokens, and more.

Instructions

Chat completion (OpenAI-compatible)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
apiUrlNohttp://localhost:5001
max_tokensNo
messagesYes
stopNo
temperatureNo
top_pNo

Implementation Reference

  • Executes the kobold_chat tool: maintains in-memory chat history, appends new messages, sends request to KoboldAI /v1/chat/completions endpoint with full history, appends response to history, and returns the result.
    if (name === 'kobold_chat') { // Add new messages to chat history const newMessages = (requestData as any).messages || []; chatHistory.push(...newMessages); // Get last 4 messages const recentMessages = chatHistory.slice(-4); console.error('Last 4 messages in chat:'); console.error(JSON.stringify(recentMessages, null, 2)); // Make the API request with all context const result = await makeRequest( `${apiUrl}/v1/chat/completions`, 'POST', { ...requestData, messages: chatHistory } ); // Add assistant's response to history const typedResult = result as any; if (typedResult.choices?.[0]?.message) { chatHistory.push(typedResult.choices[0].message); } return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }], isError: false, }; }
  • Zod schema defining input parameters for kobold_chat tool, extending BaseConfigSchema with messages array, temperature, top_p, max_tokens, and stop sequences.
    const ChatCompletionSchema = BaseConfigSchema.extend({ messages: z.array(z.object({ role: z.enum(['system', 'user', 'assistant']), content: z.string(), })), temperature: z.number().optional(), top_p: z.number().optional(), max_tokens: z.number().optional(), stop: z.array(z.string()).optional(), });
  • src/index.ts:260-264 (registration)
    Registers the kobold_chat tool in the MCP server's listTools response with name, description, and input schema reference.
    { name: "kobold_chat", description: "Chat completion (OpenAI-compatible)", inputSchema: zodToJsonSchema(ChatCompletionSchema), },
  • In-memory array storing chat history (system/user/assistant messages) specifically used by the kobold_chat handler.
    const chatHistory: Array<{ role: 'system' | 'user' | 'assistant', content: string }> = [];

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/PhialsBasement/KoboldCPP-MCP-Server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server