Skip to main content
Glama
irad-bouzidi

mcp-ollama-account-rotation

by irad-bouzidi

mcp-ollama-account-rotation

MCP server that transparently routes Ollama Cloud API requests across multiple user-owned accounts, handling quota exhaustion, rate limits, and failures via automatic account rotation.

Architecture

┌──────────────────────────────────────────┐
│              MCP Client                   │
│    (Claude Code / OpenCode / etc.)       │
└─────────────────┬────────────────────────┘
                  │ MCP Protocol (stdio/SSE)
                  ▼
┌──────────────────────────────────────────┐
│          FastMCP Server                   │
│   Tools: chat, generate, list_models     │
│   Resources: models://, accounts://      │
├──────────────────────────────────────────┤
│          Request Router                   │
│   select account → forward → classify    │
├──────────────────────────────────────────┤
│   Account Manager    │   Retry Engine    │
│   State Manager      │   Health Checker  │
│   HTTP Client        │   Logger/Metrics  │
└──────────────────────────────────────────┘
                  │
                  ▼
         Ollama Cloud API
    https://api.ollama.com

Related MCP server: Ollama MCP Proxy

Installation

# Prerequisites: Python 3.11+
pip install -e .
# Or with uv:
uv sync

Configuration

Edit data/config.yaml:

ollama_base_url: "https://api.ollama.com"
retry:
  max_attempts: 3
  backoff_base: 2.0
  backoff_max: 60.0
  jitter: 0.1
rotation:
  strategy: "round_robin"
health:
  interval_seconds: 60
  timeout_seconds: 10
timeouts:
  request_seconds: 60
  connect_seconds: 10
logging:
  level: "INFO"
  format: "json"
  output: "console"

Account Setup

Add accounts to data/accounts.json:

{
  "accounts": [
    {
      "email": "user1@example.com",
      "api_key": "ollama-api-key-1"
    },
    {
      "email": "user2@example.com",
      "api_key": "ollama-api-key-2"
    }
  ]
}

Usage

CLI

# stdio transport (default)
ollama-router

# custom config
ollama-router -c /path/to/config.yaml

# SSE transport
ollama-router --transport sse --port 8000

MCP Client Integration

OpenCode (opencode.json):

{
  "mcpServers": {
    "ollama-router": {
      "command": "ollama-router",
      "args": ["-c", "data/config.yaml"]
    }
  }
}

Claude Code (claude.json):

{
  "mcpServers": {
    "ollama-router": {
      "command": "ollama-router",
      "args": ["-c", "data/config.yaml"]
    }
  }
}

Tools

Tool

Description

chat

Send chat completion request

generate

Send text generation request

list_models

List available models

get_account_status

Show current active account

get_metrics

Show server metrics

Development

# Install dev dependencies
pip install -e ".[dev]"

# Run tests
pytest

# Type checking
mypy app

# Linting
ruff check app
ruff format app

Log Events

Event

Description

startup

Server starts

shutdown

Server stops

account_selected

Account chosen for request

account_rotated

Rotated to different account

retry_attempt

Retrying failed request

account_recovered

Health check succeeded

all_accounts_unhealthy

No healthy accounts

License

MIT

Available Tools

5 tools
chatC

Send a chat completion request to Ollama

ParametersJSON Schema
NameRequiredDescriptionDefault
modelYes
optionsNo
messagesYes

TDQS

C2.3/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description must disclose all behavioral traits. It only states the action without mentioning side effects, idempotency, rate limits, or authentication needs. Minimal transparency.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness2/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single short sentence, but it omits critical information. It is under-specified rather than concise. Every sentence should add value, but here it fails to cover essential aspects.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness1/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity (nested objects, 3 parameters, no output schema, no annotations), the description is vastly insufficient. It does not explain return values, error handling, or how to structure the messages array. Completely inadequate for effective tool usage.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters1/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description adds no information about the parameters (model, messages, options). Schema coverage is 0%, and the description does not compensate by explaining what these parameters mean or how to use them. The agent gets no help beyond parameter names.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action: sending a chat completion request to Ollama. It specifies the verb 'send' and the resource 'chat completion request'. However, it does not differentiate from the sibling tool 'generate', which might have a similar purpose, reducing clarity.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidelines on when to use this tool versus alternatives like 'generate' or other sibling tools. The description lacks context for appropriate usage scenarios, exclusions, or prerequisites.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

generateC

Generate text using Ollama

ParametersJSON Schema
NameRequiredDescriptionDefault
modelYes
promptYes
optionsNo

TDQS

C2.5/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It only says 'generate text', omitting any details about side effects, required prerequisites, rate limits, or return behavior. This is insufficient for a tool that likely performs an important operation.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single sentence, which is concise, but it is too short to provide the necessary information for a tool with three parameters and no other documentation. Conciseness should not sacrifice completeness.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness1/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The description is extremely incomplete. It lacks any explanation of parameters, output format, usage context, or behavior. With no output schema and no parameter descriptions, the agent cannot reliably invoke this tool. This is a critical gap.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, meaning the input schema provides no explanations for the three parameters (model, prompt, options). The description does not compensate by explaining what these parameters do or how they affect generation. The agent is left guessing parameter semantics.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'Generate text using Ollama' clearly states the verb 'generate' and the resource 'text using Ollama', making the purpose understandable. However, it does not differentiate from sibling tool 'chat' which also generates text, so it gets a 4 instead of 5.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool vs alternatives like 'chat'. The description does not mention use cases or when not to use this tool, leaving the agent without decision support.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

get_account_statusA

Get current active account status

ParametersJSON Schema
NameRequiredDescriptionDefault

No parameters

TDQS

A3.5/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations provided, and the description does not disclose behavioral traits such as authentication requirements, potential errors, or the format of the status output. It only states the basic function.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence without unnecessary words. However, it could be slightly expanded for clarity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The description lacks details about the return value or what constitutes 'account status'. With no output schema, the agent is left guessing the response format.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

No parameters exist, so schema coverage is complete. The description adds value by specifying 'current active' state, which is beyond the empty schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action (Get) and the resource (current active account status), distinguishing it from sibling tools like chat, generate, etc.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No explicit guidance on when to use this tool vs alternatives, but the simple nature implies it can be called to check account status. The lack of parameters makes usage straightforward.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

get_metricsC

Get server metrics

ParametersJSON Schema
NameRequiredDescriptionDefault

No parameters

TDQS

C2.3/5.0
Behavior1/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations provided, and the description gives no behavioral traits (e.g., read-only, rate limits, data scope). The description carries full burden but fails to disclose any behavioral context.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

At three words, it is very concise but lacks necessary detail. Could be more informative while remaining brief.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

With no output schema, no annotations, and a minimal description, the tool definition is incomplete. It does not explain what the metrics represent, possible return values, or side effects.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100% (no parameters), baseline is 3. Description adds no parameter-specific meaning beyond 'metrics', but no parameters exist to describe.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'Get server metrics' is a clear verb+resource, but it is vague about what specific metrics and which server, and does not distinguish from siblings like chat or list_models.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance on when to use this tool versus alternatives. Context signals show siblings are unrelated, but description implies no specific context for use.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

list_modelsB

List available models

ParametersJSON Schema
NameRequiredDescriptionDefault

No parameters

TDQS

B3/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description bears the full burden of behavioral disclosure. It only says 'List available models' with no mention of sorting, filtering, rate limits, or any side effects. For a zero-parameter tool, minimal transparency is acceptable, but the description adds no value beyond the name.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise—one short phrase. It is front-loaded and easy to parse. However, it could be slightly more structured (e.g., 'Lists all models that are currently available for use.') without losing conciseness.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no output schema, the description should explain what the return value contains. It does not. For a listing operation, users need to know if it returns model IDs, names, metadata, etc. The description is incomplete for a tool with no output schema.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

There are zero parameters, so the baseline score is 4. The description adds meaning by specifying that the tool lists 'available models', which clarifies what is returned. No additional parameter details are needed.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('List') and resource ('available models'). It is a specific verb+resource pair. However, it does not differentiate from sibling tools like 'get_account_status' or 'get_metrics', which also retrieve information. Still, the purpose is clear.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. There is no mention of context, prerequisites, or when not to use it. As a simple listing tool, it might be self-evident, but the absence of any usage instructions lowers the score.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

TDQS

C2.4/5.0
Disambiguation2/5

'chat' and 'generate' both involve text generation with overlapping functionality, making them hard to distinguish without additional context. The account-related tools (get_account_status, get_metrics) are distinct but mixed with unrelated generation tools, causing ambiguity about the server's core purpose.

Naming Consistency2/5

Tool names use inconsistent patterns: 'chat' and 'generate' are single verbs, while 'list_models', 'get_account_status', and 'get_metrics' follow snake_case verb_noun. Mixing styles reduces predictability.

Tool Count3/5

Five tools is a reasonable number, but the scope is muddled: only two tools (get_account_status, get_metrics) relate to the server's stated 'account rotation' purpose, while the others provide generic Ollama functionality, making the count feel imbalanced.

Completeness2/5

For an account rotation server, essential operations like switching accounts, listing accounts, or rotating keys are missing. The existing account tools are limited to status and metrics, leaving significant gaps that would hinder automation.

Maintenance

ActivityMaintained
ResponsivenessSyncing

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    C
    maintenance
    An MCP server that functions as an intelligent gateway for multiple LLM backends including OpenAI, Claude, and Ollama. It supports automatic provider fallback, streaming responses via Server-Sent Events, and real-time monitoring for robust AI integration.
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    A comprehensive MCP proxy server that bridges MCP clients with Ollama local language models, providing advanced features like RAG integration, context management, caching, and production-ready security.
    1
    MIT
  • A
    license
    A
    quality
    D
    maintenance
    MCP server for ProxyLLM, the OpenAI-compatible LLM gateway, enabling live model catalogs, plan-savings calculations, routing key management, and autonomous account signup.
    9
    123
    MIT
  • F
    license
    A
    quality
    C
    maintenance
    Unified MCP server for querying multiple LLM providers (Gemini, OpenAI, Anthropic, etc.) with advanced routing, cost optimization, and fallback resilience.
    2
    15

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/irad-bouzidi/mcp-ollama-account-rotation-new'

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