Skip to main content
Glama

AI Optimizer MCP 🧠🔧 - Multi-Task MCP Server

Developed by Barack Ndenga ♥️

PyPI version Tests Coverage

Details

Multi-task MCP Server for VSCode/Cursor, CLI, autonomous agents. AI code optimization + testing + extensible.

  • Transports: Stdio (VSCode), subprocess, HTTP (future)

  • Use Cases: VSCode chat, agent loops, CI/CD, remote servers

  • Security: Env vars, sandbox exec

Related MCP server: VegaMCP

Manifesto (Multi-Task Capabilities)

  • 🛠️ 3+ Tools: Code test/optimize/objective (+extensible)

  • 🔌 VSCode/Cursor: native mcp.json

  • 🖥️ CLI Standalone: ai-optimizer-mcp run

  • 🤖 Agents: examples/agent.py loop

  • ⚙️ Multi-Env: Local/dev/prod via .env

  • 📊 Memory/History: Persistent JSON

  • 🔄 Iterative Loops: Auto-improve

Multi-Platform Configuration

.vscode/mcp.json file (multi-servers):

{
  "servers": {
    "ai-optimizer": {
      "command": "python",
      "args": ["-m", "ai_optimizer_mcp.server"]
    },
    "ai-optimizer-dev": {
      "command": "python",
      "args": ["-m", "ai_optimizer_mcp.cli", "run", "--dev"]
    }
  }
}

Multi-task: Switch servers in chat!

2. CLI / Scripts / Agents

ai-optimizer-mcp run  # Stdio server (pipes)
ai-optimizer-mcp run --dev  # Debug
ai-optimizer-mcp --install-mcp  # Print mcp.json

3. Autonomous Agents / Subprocess

# examples/agent.py
import asyncio
from mcp.client.stdio import stdio_client

async def agent_loop():
    async with stdio_client(command=["python", "-m", "ai_optimizer_mcp.server"]) as client:
        # Multi-task calls
        score = await client.call_tool("run_tests", {"code_snippet": code})
        improved = await client.call_tool("generate_improvement", {"code": code, "test_result": score})

Prerequisites (.env)

cp .env.example .env
# OPENAI_API_KEY=sk-...
# OBJECTIVE="Your custom goal"

Multi-Task Usage

  1. VSCode Chat: use_mcp_tool("ai-optimizer", "run_tests", ...)

  2. CLI Pipe: echo code | ai-optimizer-mcp run

  3. Agent Loop: python examples/agent.py

  4. CI/CD: Subprocess in GitHub Actions/Jenkins

Tool Response Example:

run_tests → "Tests passed: score=4/4 (f(2)=4)"
generate_improvement → "def f(x): return 2 * x"

Multi-Env Troubleshooting

  • VSCode: Reload window after mcp.json

  • No API Key: ValueError → Check .env

  • Timeout: TEST_TIMEOUT=10 in .env

  • Memory: rm memory.json

  • Logs: --dev or LOG_LEVEL=DEBUG

Development

pip install -e .[dev]
pre-commit install
pytest

MCP Tools (Extensible)

Tool

Args

Use Case

run_tests

code_snippet: str

VSCode/CLI test code

generate_improvement

code, test_result

Auto-optimize

get_objective

-

Read goal any context

Apache 2.0 - Multi-task ready! VSCode, CLI, Agents, CI. Contribute!

CHANGELOG

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      Not graded
      quality
      D
      maintenance
      A lightweight MCP server that enhances AI agents with tools for codebase analysis, task delegation to sub-agents, multi-agent coordination through chatrooms, and project todo management.
      -
    • A
      license
      Not graded
      quality
      C
      maintenance
      MCP server that enables AI coding agents to communicate, share state, and coordinate work in real time via MCP tools or REST API.
      79 npm
      10
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Multi-agent AI orchestrator that runs parallel coding agents in isolated sessions with self-improving intelligence, exposed via an MCP server for task execution and management.
      MIT