Skip to main content
Glama

kobold_generate

Generate text using AI by inputting prompts and adjusting parameters like length, temperature, and repetition penalty. Integrates with Kobold MCP Server for enhanced text generation capabilities.

Instructions

Generate text with KoboldAI

Input Schema

NameRequiredDescriptionDefault
apiUrlNohttp://localhost:5001
max_context_lengthNo
max_lengthNo
promptYes
repetition_penaltyNo
seedNo
stop_sequenceNo
temperatureNo
top_kNo
top_pNo

Input Schema (JSON Schema)

{ "$schema": "http://json-schema.org/draft-07/schema#", "additionalProperties": false, "properties": { "apiUrl": { "default": "http://localhost:5001", "type": "string" }, "max_context_length": { "type": "number" }, "max_length": { "type": "number" }, "prompt": { "type": "string" }, "repetition_penalty": { "type": "number" }, "seed": { "type": "number" }, "stop_sequence": { "items": { "type": "string" }, "type": "array" }, "temperature": { "type": "number" }, "top_k": { "type": "number" }, "top_p": { "type": "number" } }, "required": [ "prompt" ], "type": "object" }

Implementation Reference

  • Zod schema defining the input parameters for the kobold_generate tool (prompt, sampling parameters, etc.). Used for validation and inputSchema in registration.
    const GenerateSchema = BaseConfigSchema.extend({ prompt: z.string(), max_length: z.number().optional(), max_context_length: z.number().optional(), temperature: z.number().optional(), top_p: z.number().optional(), top_k: z.number().optional(), repetition_penalty: z.number().optional(), stop_sequence: z.array(z.string()).optional(), seed: z.number().optional(), });
  • src/index.ts:177-181 (registration)
    Registration of the kobold_generate tool in the ListTools response, specifying name, description, and input schema.
    { name: "kobold_generate", description: "Generate text with KoboldAI", inputSchema: zodToJsonSchema(GenerateSchema), },
  • Handler dispatch for kobold_generate (and other POST tools): maps tool name to KoboldAI API endpoint '/api/v1/generate', validates input with schema, proxies POST request to API, returns JSON response.
    const postEndpoints: Record<string, { endpoint: string; schema: z.ZodTypeAny }> = { kobold_multiplayer_status: { endpoint: '/api/extra/multiplayer/status', schema: MultiplayerStatusSchema }, kobold_multiplayer_get_story: { endpoint: '/api/extra/multiplayer/getstory', schema: MultiplayerGetStorySchema }, kobold_multiplayer_set_story: { endpoint: '/api/extra/multiplayer/setstory', schema: MultiplayerSetStorySchema }, kobold_generate_check_multiuser: { endpoint: '/api/extra/generate/check', schema: GenerateCheckMultiuserSchema }, kobold_generate: { endpoint: '/api/v1/generate', schema: GenerateSchema }, kobold_token_count: { endpoint: '/api/extra/tokencount', schema: TokenCountSchema }, kobold_detokenize: { endpoint: '/api/extra/detokenize', schema: DetokenizeSchema }, kobold_transcribe: { endpoint: '/api/extra/transcribe', schema: TranscribeSchema }, kobold_web_search: { endpoint: '/api/extra/websearch', schema: WebSearchSchema }, kobold_tts: { endpoint: '/api/extra/tts', schema: TTSSchema }, kobold_abort: { endpoint: '/api/extra/abort', schema: AbortSchema }, kobold_last_logprobs: { endpoint: '/api/extra/last_logprobs', schema: LastLogProbsSchema }, kobold_txt2img: { endpoint: '/sdapi/v1/txt2img', schema: Txt2ImgSchema }, kobold_img2img: { endpoint: '/sdapi/v1/img2img', schema: Img2ImgSchema }, kobold_interrogate: { endpoint: '/sdapi/v1/interrogate', schema: InterrogateSchema }, kobold_complete: { endpoint: '/v1/completions', schema: CompletionSchema }, }; if (postEndpoints[name]) { const { endpoint, schema } = postEndpoints[name]; const parsed = schema.safeParse(args); if (!parsed.success) { throw new Error(`Invalid arguments: ${parsed.error}`); } const result = await makeRequest(`${apiUrl}${endpoint}`, 'POST', requestData); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }], isError: false, }; }
  • Helper function used by all tool handlers to make HTTP requests to the KoboldAI backend API.
    async function makeRequest(url: string, method = 'GET', body: Record<string, unknown> | null = null) { const options: RequestInit = { method, headers: body ? { 'Content-Type': 'application/json' } : undefined, }; if (body && method !== 'GET') { options.body = JSON.stringify(body); } const response = await fetch(url, options); if (!response.ok) { throw new Error(`KoboldAI API error: ${response.statusText}`); } return response.json(); }

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