Skip to main content
Glama

ask-coding-advisors

Get coding assistance by querying three AI specialists simultaneously for multiple expert opinions on programming questions, with automatic fallback to premium models when needed.

Instructions

Queries three OpenRouter coding specialists (free tier) and falls back to premium models when rate limited.

Input Schema

NameRequiredDescriptionDefault
questionYes
contextNo

Input Schema (JSON Schema)

{ "properties": { "context": { "maxLength": 12000, "type": "string" }, "question": { "maxLength": 4000, "minLength": 4, "type": "string" } }, "required": [ "question" ], "type": "object" }

Implementation Reference

  • The MCP tool handler function: processes args into ToolInput, calls coordinator.advise(), formats results with formatBatch, returns text content, handles and exposes retryable errors.
    async (args) => { const input: ToolInput = typeof args.context === 'string' && args.context.length > 0 ? { question: args.question, context: args.context } : { question: args.question }; try { const batch = await coordinator.advise(input); const formatted = formatBatch(batch); return { content: [ { type: 'text', text: formatted, }, ], }; } catch (error) { const prefix = 'Coding advisor tool failed'; const message = error instanceof Error ? `${prefix}: ${error.message}` : `${prefix}: ${String(error)}`; const isRetryable = error instanceof RateLimitError || error instanceof OpenRouterError; return { isError: isRetryable, content: [ { type: 'text', text: message, }, ], }; } } );
  • Zod schema for tool input validation: required 'question' (4-4000 chars) and optional 'context' (max 12000 chars).
    const inputSchema = z.object({ question: z .string() .min(4, 'Bitte fasse dein Problem in mindestens vier Zeichen zusammen.') .max(4000, 'Question too long (4k char cap).'), context: z.string().max(12000).optional(), });
  • src/server.ts:44-51 (registration)
    MCP server tool registration: name, title, description, and references inputSchema and handler function.
    server.registerTool( 'ask-coding-advisors', { title: 'Ask Coding Advisors', description: 'Queries three OpenRouter coding specialists (free tier) and falls back to premium models when rate limited.', inputSchema, },
  • CodingAdvisorCoordinator.advise(): Orchestrates querying up to 3 coding advisor models via OpenRouter, prefers free tier, falls back to paid on rate limits, collects results.
    async advise(input: ToolInput): Promise<AdvisorBatchResult> { const answers: AdvisorCallResult[] = []; const lineup = buildModelLineup(input); let fallbackTriggered = false; const freePool = this.freeDisabled ? [] : lineup.free; for (const spec of freePool) { if (answers.length >= 3) break; const outcome = await this.tryModel(spec, lineup.tags, input, false); if (outcome?.type === 'rate-limit') { fallbackTriggered = true; break; } if (outcome?.result) { answers.push(outcome.result); } if (this.freeDisabled) { break; } } if (answers.length < 3) { fallbackTriggered = true; for (const spec of lineup.paid) { if (answers.length >= 3) break; const outcome = await this.tryModel(spec, lineup.tags, input, true); if (outcome?.result) { answers.push(outcome.result); } } } if (answers.length < 3) { throw new Error('Keine gesunden OpenRouter-Modelle verfügbar – bitte später erneut versuchen.'); } return { answers, fallbackTriggered }; }
  • formatBatch(): Formats advisor batch results into a human-readable string with fallback warning, per-advisor details (model, tier, latency, usage, focus, response).
    function formatBatch(batch: AdvisorBatchResult): string { const header = batch.fallbackTriggered ? '⚠️ OpenRouter rate limit hit — switched to paid fallbacks for the remaining slots.\n' : ''; const body = batch.answers .map((answer, index) => { const tier = answer.isFree ? 'free tier' : answer.usedFallback ? 'paid fallback' : 'paid'; const latency = formatLatency(answer.latencyMs); const usageBits = formatUsage(answer.usage); return [ `Advisor ${index + 1}: ${answer.modelLabel} (${tier})`, `Focus: ${answer.focus}`, `Latency: ${latency}${usageBits ? ` | Usage: ${usageBits}` : ''}`, '', answer.responseText, ].join('\n'); }) .join('\n\n---\n\n'); return header + body; }

Other Tools

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/meinzeug/mcp-ai-bug-helper'

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