kobold_detokenize
Convert token IDs into readable text using the Kobold MCP Server. Ideal for decoding processed token data into clear, human-readable output.
Instructions
Convert token IDs to text
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| apiUrl | No | http://localhost:5001 | |
| tokens | Yes |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"apiUrl": {
"default": "http://localhost:5001",
"type": "string"
},
"tokens": {
"items": {
"type": "number"
},
"type": "array"
}
},
"required": [
"tokens"
],
"type": "object"
}
Implementation Reference
- src/index.ts:346-358 (handler)Generic handler logic for POST endpoint tools like kobold_detokenize: validates arguments using the tool's schema, proxies POST request to the KoboldAI API endpoint, and returns the JSON response as text content.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, }; }
- src/index.ts:50-52 (schema)Zod schema definition for kobold_detokenize tool inputs: optional apiUrl and required tokens array of numbers.const DetokenizeSchema = BaseConfigSchema.extend({ tokens: z.array(z.number()), });
- src/index.ts:203-207 (registration)Registers kobold_detokenize in the list of available tools returned by ListToolsRequestHandler, including name, description, and input schema.{ name: "kobold_detokenize", description: "Convert token IDs to text", inputSchema: zodToJsonSchema(DetokenizeSchema), },
- src/index.ts:334-334 (registration)Maps the kobold_detokenize tool name to its corresponding KoboldAI API endpoint and schema in the postEndpoints lookup object used by the CallTool handler.kobold_detokenize: { endpoint: '/api/extra/detokenize', schema: DetokenizeSchema },
- src/index.ts:146-162 (helper)Helper function used by all proxy tools, including kobold_detokenize, to make HTTP requests to the KoboldAI server.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(); }