kobold_max_context_length
Retrieve the maximum context length setting from KoboldAI's text generation server to manage input size for optimal performance.
Instructions
Get current max context length setting
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| apiUrl | No | http://localhost:5001 |
Implementation Reference
- src/index.ts:318-323 (handler)Handler logic that executes the tool: performs a GET request to the KoboldAI API endpoint '/api/v1/config/max_context_length' and returns the JSON response as text content.if (getEndpoints[name]) { const result = await makeRequest(`${apiUrl}${getEndpoints[name]}`); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }], isError: false, };
- src/index.ts:11-16 (schema)Zod schema definition for tool input (optional apiUrl), referenced as MaxContextLengthSchema and converted to JSON schema in registration.const BaseConfigSchema = z.object({ apiUrl: z.string().default('http://localhost:5001'), }); // Core API schemas (api/v1) const MaxContextLengthSchema = BaseConfigSchema;
- src/index.ts:167-171 (registration)Tool registration in the ListTools response, specifying name, description, and input schema.{ name: "kobold_max_context_length", description: "Get current max context length setting", inputSchema: zodToJsonSchema(MaxContextLengthSchema), },
- src/index.ts:307-316 (helper)Dispatch table mapping tool name to the corresponding KoboldAI GET endpoint.const getEndpoints: Record<string, string> = { kobold_max_context_length: '/api/v1/config/max_context_length', kobold_max_length: '/api/v1/config/max_length', kobold_generate_check: '/api/extra/generate/check', kobold_model_info: '/api/v1/model', kobold_version: '/api/v1/info/version', kobold_perf_info: '/api/extra/perf', kobold_sd_models: '/sdapi/v1/sd-models', kobold_sd_samplers: '/sdapi/v1/samplers', };
- src/index.ts:146-162 (helper)Generic HTTP request helper function used by the tool handler to proxy 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(); }