Skip to main content
Glama

kobold_token_count

Measure the token count of text for accurate processing and compatibility with KoboldAI MCP Server, ensuring efficient integration with text generation workflows.

Instructions

Count tokens in text

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
apiUrlNohttp://localhost:5001
textYes

Implementation Reference

  • Shared handler logic for POST-based tools like kobold_token_count: validates arguments against schema, forwards POST request to the configured KoboldAI endpoint, and returns the JSON response.
    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, }; }
  • Zod schema defining input for kobold_token_count: optional apiUrl and required text string.
    const TokenCountSchema = BaseConfigSchema.extend({ text: z.string(), });
  • src/index.ts:198-202 (registration)
    Tool registration in ListTools response, including name, description, and input schema.
    { name: "kobold_token_count", description: "Count tokens in text", inputSchema: zodToJsonSchema(TokenCountSchema), },
  • Configuration mapping the kobold_token_count tool to its KoboldAI proxy endpoint.
    kobold_token_count: { endpoint: '/api/extra/tokencount', schema: TokenCountSchema },

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