Skip to main content
Glama
anaseqal

MCP Code Mode

by anaseqal

MCP Code Mode šŸāš”

Universal Python code execution MCP server - one tool to rule them all.

Inspired by Cloudflare's Code Mode: LLMs are better at writing code than making tool calls because they've trained on millions of real repositories.

Why Code Mode?

Traditional approach (many tools):

User: "Get weather for Austin and save to file"

LLM: [tool_call: get_weather(location="Austin")]
     → waits for response...
LLM: [tool_call: write_file(path="weather.txt", content=...)]
     → waits for response...

Code Mode approach (one tool):

User: "Get weather for Austin and save to file"

LLM: [run_python]
import requests
weather = requests.get("https://wttr.in/Austin?format=j1").json()
temp = weather['current_condition'][0]['temp_F']
with open("weather.txt", "w") as f:
    f.write(f"Austin: {temp}°F")
print(f"Saved! Temperature: {temp}°F")

Benefits

Traditional Tools

Code Mode

āŒ LLMs struggle with synthetic tool-call format

āœ… LLMs excel at writing real code

āŒ Each tool call = round trip to LLM

āœ… Complex workflows in one execution

āŒ Managing 20+ extensions

āœ… One universal tool

āŒ Token waste passing data between calls

āœ… Efficient data flow in code

āŒ Limited to pre-built capabilities

āœ… Anything Python can do

Related MCP server: MCP Server

Works With Any MCP Client

  • āœ… Goose (Block's AI agent)

  • āœ… Claude Desktop

  • āœ… Cursor

  • āœ… VS Code with Copilot

  • āœ… Any MCP-compatible agent

Features

šŸš€ Universal Execution

Write Python to accomplish any task - HTTP requests, file operations, data processing, web scraping, image manipulation, and more.

šŸ“¦ Auto-Install Dependencies

Missing a package? Code Mode detects ModuleNotFoundError, installs the package, and retries automatically.

🌊 Streaming Output

See results in real-time! run_python_stream shows output line-by-line as your code executes. Perfect for long-running tasks, progress bars, and monitoring live operations.

šŸ–¼ļø Automatic File Display (Goose Compatible!)

Generated images, logs, or data files? Code Mode automatically detects and displays them in your MCP client! Supports:

  • Images: PNG, JPG, GIF, SVG, HEIC, TIFF, etc. (displayed inline)

  • Text Files: JSON, logs, source code (Python, JS, TS, Go, Rust, etc.), CSV, YAML, etc. (shown with syntax highlighting)

  • Resources: PDFs, archives, videos (MP4, MOV), audio (MP3, WAV), Office docs, databases (available for download)

Just print the file path and Code Mode handles the rest! Works seamlessly with Goose and other MCP clients.

🧠 Dual Learning System (Enhanced!)

Records both error-based and semantic failures:

  • Error Learning: Captures errors (ModuleNotFoundError, SSL errors, etc.) and their solutions

  • Semantic Learning: Learns when code runs successfully but doesn't accomplish the objective

Future executions benefit from past learnings. Persists across sessions.

šŸ”„ Intelligent Retry

run_with_retry analyzes failures and suggests fixes based on both error patterns and semantic learnings from similar tasks.

🐳 Optional Docker Sandbox

Run code in isolated Docker containers for enhanced security.

āš™ļø Configurable

Adjust timeouts, execution modes, package restrictions, and more.

Installation

From PyPI (when published)

# Using uv (recommended)
uv tool install mcp-pyrunner

# Using pip
pip install mcp-pyrunner

From Source

git clone https://github.com/anaseqal/codemode.git
cd codemode
uv sync

Configuration

Goose

If installed from PyPI:

Edit ~/.config/goose/config.yaml:

extensions:
  codemode:
    type: stdio
    enabled: true
    cmd: uvx
    args: ["mcp-pyrunner"]

If running from source (local development):

extensions:
  codemode:
    type: stdio
    enabled: true
    cmd: uv
    args: ["run", "--directory", "/path/to/codemode", "mcp-pyrunner"]
    # Replace /path/to/codemode with actual path (e.g., ~/codemode)

Or use the UI: Extensions → Add Custom Extension → STDIO → Command: uv run --directory /path/to/codemode mcp-pyrunner

Claude Desktop

Edit ~/Library/Application Support/Claude/claude_desktop_config.json:

If installed from PyPI:

{
  "mcpServers": {
    "codemode": {
      "command": "uvx",
      "args": ["mcp-pyrunner"]
    }
  }
}

If running from source:

{
  "mcpServers": {
    "codemode": {
      "command": "uv",
      "args": ["run", "--directory", "/path/to/codemode", "mcp-pyrunner"]
    }
  }
}

Cursor

Add to .cursor/mcp.json:

If installed from PyPI:

{
  "mcpServers": {
    "codemode": {
      "command": "uvx",
      "args": ["mcp-pyrunner"]
    }
  }
}

If running from source:

{
  "mcpServers": {
    "codemode": {
      "command": "uv",
      "args": ["run", "--directory", "/path/to/codemode", "mcp-pyrunner"]
    }
  }
}

Available Tools

Tool

Description

get_system_context

Get environment info (OS, Python, pip versions, package managers, learnings)

run_python

Execute Python code (auto-installs packages, auto-displays files)

run_python_stream

Execute with real-time streaming output (auto-displays files)

run_with_retry

Execute with intelligent retry, error analysis, and semantic learning suggestions

add_learning

Record error-based solutions for future reference

record_semantic_failure

NEW! Record when code runs but doesn't accomplish objective

get_learnings

View/search past learnings (both error and semantic)

pip_install

Pre-install a specific package

configure

View/update settings

Usage Examples

Web Scraping

User: "Scrape the top 10 posts from Hacker News"

→ run_python:
import requests
from bs4 import BeautifulSoup

resp = requests.get("https://news.ycombinator.com")
soup = BeautifulSoup(resp.text, "html.parser")

for i, item in enumerate(soup.select(".titleline > a")[:10], 1):
    print(f"{i}. {item.text}")
    print(f"   {item['href']}\n")

Data Processing

User: "Analyze sales.csv and show monthly totals"

→ run_python:
import pandas as pd

df = pd.read_csv("sales.csv")
df["date"] = pd.to_datetime(df["date"])
monthly = df.groupby(df["date"].dt.to_period("M"))["amount"].sum()

print("Monthly Sales:")
for period, total in monthly.items():
    print(f"  {period}: ${total:,.2f}")

API Integration

User: "Get the current Bitcoin price in USD"

→ run_python:
import requests

data = requests.get("https://api.coinbase.com/v2/prices/BTC-USD/spot").json()
price = float(data["data"]["amount"])
print(f"Bitcoin: ${price:,.2f} USD")

Image Processing

User: "Resize all images in ./photos to 800x600"

→ run_python:
from pathlib import Path
from PIL import Image

photos = Path("./photos")
for img_path in photos.glob("*.jpg"):
    img = Image.open(img_path)
    img.thumbnail((800, 600))
    img.save(img_path)
    print(f"Resized: {img_path.name}")

Streaming Output (Real-Time Progress)

User: "Scrape top 20 HN posts with progress updates"

→ run_python_stream:
import requests
from bs4 import BeautifulSoup
import time

print("šŸ” Starting to scrape Hacker News...")

resp = requests.get("https://news.ycombinator.com")
soup = BeautifulSoup(resp.text, "html.parser")
stories = soup.select(".titleline > a")[:20]

print(f"šŸ“Š Found {len(stories)} stories. Processing...\n")

for i, story in enumerate(stories, 1):
    # Show progress in real-time
    progress = "ā–ˆ" * i + "ā–‘" * (20 - i)
    print(f"[{progress}] {i}/20: {story.text}")
    time.sleep(0.5)  # See each item appear live!

print("\nāœ… Scraping complete!")

# Output appears LINE BY LINE as the code runs,
# not all at once at the end!

Automatic File Display

User: "Take a screenshot of example.com and create a summary report"

→ run_python:
from playwright.sync_api import sync_playwright
import json

with sync_playwright() as p:
    browser = p.chromium.launch()
    page = browser.new_page()
    page.goto("https://example.com")

    # Take screenshot
    screenshot_path = "/tmp/example_screenshot.png"
    page.screenshot(path=screenshot_path)

    # Create report
    report = {
        "url": "https://example.com",
        "title": page.title(),
        "screenshot": screenshot_path,
        "timestamp": "2025-01-26T12:00:00"
    }

    report_path = "/tmp/report.json"
    with open(report_path, "w") as f:
        json.dump(report, f, indent=2)

    browser.close()

    # Print file paths - Code Mode auto-detects and displays them!
    print(f"Screenshot saved to: {screenshot_path}")
    print(f"Report saved to: {report_path}")

# Result: Your MCP client displays the screenshot IMAGE inline
# and shows the JSON content formatted - no manual handling needed!

Configuration Options

View current config:

→ configure()

Update settings:

→ configure(action="set", key="execution_mode", value="docker")
→ configure(action="set", key="default_timeout", value="120")

Setting

Values

Description

execution_mode

direct, docker

How to run code

default_timeout

integer

Default timeout (seconds)

max_retries

integer

Default retry attempts

auto_install

true, false

Auto-install packages

docker_image

string

Docker image for sandbox

Dual Learning System

Code Mode learns from two types of failures:

1. Error-Based Learning

When you solve an error, record it:

→ add_learning(
    error_pattern="SSL: CERTIFICATE_VERIFY_FAILED",
    solution="Use verify=False or install/update certifi",
    context="HTTPS requests on systems with cert issues",
    tags="ssl,https,certificates"
)

2. Semantic Learning (NEW!)

When code runs successfully but doesn't accomplish the objective:

→ record_semantic_failure(
    objective="Display image in Goose app",
    failed_approach="Used print() to output file path",
    successful_approach="Returned base64 encoded image as MCP content object",
    context="MCP clients need structured content objects, not just paths",
    tags="goose,mcp,display,images"
)

Why semantic learning matters:

  • Code executed without errors ≠ objective accomplished

  • AI learns from "technically correct but semantically wrong" approaches

  • Future attempts at similar objectives benefit from past semantic learnings

View Learnings

→ get_learnings()              # View all learnings (error + semantic)
→ get_learnings(search="ssl")  # Search learnings

Learnings are distinguished by icons:

  • šŸ”“ Error-based learnings

  • šŸ”µ Semantic learnings

Learnings persist in ~/.mcp-pyrunner/learnings.json and improve future executions.

Data Storage

Code Mode stores data in ~/.mcp-pyrunner/:

~/.mcp-pyrunner/
ā”œā”€ā”€ config.json       # User configuration
ā”œā”€ā”€ learnings.json    # Error patterns and solutions
└── execution_log.json # Recent execution history

Security Considerations

āš ļø Code Mode executes arbitrary Python code.

Direct mode (default):

  • Code runs with your user permissions

  • Full filesystem and network access

  • Fast execution

Docker mode (more secure):

  • Code runs in isolated container

  • Limited resources (512MB RAM, 1 CPU)

  • Network access available

  • Slower startup

Enable Docker mode:

→ configure(action="set", key="execution_mode", value="docker")

Testing

# Run tests
uv run pytest

# Test with MCP Inspector
uv run mcp dev src/mcp_codemode/server.py
# Open http://localhost:5173

Contributing

Contributions welcome! Areas of interest:

  • Streaming output for long-running code āœ… DONE!

  • Automatic file display (images, text, resources) āœ… DONE!

  • Enhanced system context (pip version, package managers) āœ… DONE!

  • Vector DB for semantic learning search

  • Pyodide/WASM sandboxing option

  • Code analysis before execution

  • Resource usage tracking

  • Multi-file project support

License

MIT

Acknowledgments

Available Tools

9 tools
add_learningA

Record a learning from a code execution for future reference.

When you figure out how to fix an error, record it here. Future executions will suggest this solution for similar errors.

Args: error_pattern: Text/regex that matches the error message solution: What fixed the problem context: When this solution applies tags: Comma-separated tags (e.g., "network,ssl,https")

Example: add_learning( error_pattern="SSL: CERTIFICATE_VERIFY_FAILED", solution="Add verify=False to requests.get() or install certifi", context="HTTPS requests on systems with certificate issues", tags="ssl,https,certificates" )

Returns: Confirmation message

ParametersJSON Schema
NameRequiredDescriptionDefault
error_patternYes
solutionYes
contextYes
tagsNo

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A4.1/5.0
Behavior3/5

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

No annotations provided, so description must cover behavior. It notes that learning will be suggested for similar errors, but does not disclose details like storage persistence, duplicate handling, or side effects.

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?

Well-structured with clear sections, example, and return info. Could be slightly more concise but remains readable and informative.

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

Completeness4/5

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

Fairly complete for a 4-parameter tool with no output schema; covers what each parameter does and typical usage. Could mention behavior for duplicate patterns or storage limits.

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?

Schema coverage is 0%, so description compensates by explaining each parameter (error_pattern, solution, context, tags) with brief descriptions and a full example, adding meaning beyond parameter names.

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 'Record a learning from a code execution for future reference' and provides a concrete example. It distinguishes from sibling tools like get_learnings (retrieval) effectively.

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

Usage Guidelines4/5

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

Explicitly says 'When you figure out how to fix an error, record it here' and mentions future suggestion. Does not explicitly list when not to use, but sibling tools cover alternative actions.

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

configureA

View or update Code Mode configuration.

Args: action: "view" to see config, "set" to update a value key: Config key to update (for action="set") value: New value (for action="set")

Available settings:

  • execution_mode: "direct" (fast) or "docker" (secure sandbox)

  • default_timeout: Default execution timeout in seconds

  • max_retries: Default max retry attempts

  • auto_install: Whether to auto-install packages (true/false)

  • docker_image: Docker image for sandbox mode

Examples: configure() # View current config configure(action="set", key="execution_mode", value="docker") configure(action="set", key="default_timeout", value="120")

Returns: Current configuration or update confirmation

ParametersJSON Schema
NameRequiredDescriptionDefault
actionNoview
keyNo
valueNo

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A4.6/5.0
Behavior4/5

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

The description details actions and available settings, disclosing behavioral traits such as the effect of 'set' action. It does not mention persistence or side effects, but this is acceptable for a configuration tool. No annotation contradiction.

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

Conciseness5/5

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

The description is well-organized into Args, Available settings, Examples, and Returns. It is concise yet complete, with no wasted sentences.

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

Completeness5/5

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

Given three simple parameters, zero schema coverage, no annotations, and an output schema, the description thoroughly covers purpose, parameters, settings, and examples. It adds necessary context for correct tool invocation.

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

Parameters5/5

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

With 0% schema description coverage, the description fully compensates by explaining each parameter's meaning—action as 'view' or 'set', key as config key, value as new value—and listing all configurable settings. This goes well beyond the raw 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 'View or update Code Mode configuration', providing a specific verb and resource. This distinguishes it from sibling tools like run_python or pip_install, which focus on execution or installation.

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

Usage Guidelines4/5

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

The description explicitly indicates when to use 'view' vs 'set' actions. It does not explicitly state when not to use or mention alternatives, but the context of sibling tools makes the usage clear.

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

get_learningsA

View recorded learnings from past executions.

Args: search: Optional search term to filter learnings

Returns: Summary of learnings, optionally filtered

ParametersJSON Schema
NameRequiredDescriptionDefault
searchNo

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A3.5/5.0
Behavior3/5

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

With no annotations, the description discloses it's a read-only operation ('View') and mentions optional filtering. However, it lacks detail on potential side effects or idempotency.

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

Conciseness5/5

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

The description is very concise, with three lines covering purpose, parameters, and returns. No fluff, main point first.

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

Completeness4/5

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

Given an output schema exists and the tool is simple, the description covers the core functionality. Missing details like pagination are minor for this tool.

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?

Schema has 0% description coverage; the description adds meaning by explaining the 'search' parameter as an optional filter, overcoming the schema gap.

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 it views recorded learnings, using the verb 'View' and specifying the resource. It implicitly differentiates from sibling 'add_learning'.

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 explicit guidance on when to use this tool versus alternatives like 'add_learning'. The description only states what it does, not when it's appropriate.

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

get_system_contextA

Get comprehensive system context before writing code.

CALL THIS FIRST to understand:

  • OS, Python version, available paths

  • Installed and available libraries

  • Execution mode (direct or Docker sandbox)

  • Past learnings from errors

  • Tips for writing effective code

Returns detailed system information formatted for code generation.

ParametersJSON Schema
NameRequiredDescriptionDefault

No parameters

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A4.7/5.0
Behavior5/5

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

No annotations provided, so description carries full burden. It details what information is returned (OS, Python version, paths, libraries, execution mode, past learnings, tips), making behavior fully transparent.

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

Conciseness5/5

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

Description is concise: one sentence followed by a bulleted list of what it provides. Every sentence adds value, and structure is front-loaded with the main purpose.

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

Completeness5/5

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

Given zero parameters and an output schema, the description fully covers the tool's context. It explains what the tool returns and its recommended usage, leaving no gaps.

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?

Input schema has 0 parameters, so schema coverage is 100%. According to guidelines, 0 params warrants a baseline of 4. Description adds no parameter info, which is appropriate.

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 tool's purpose: 'Get comprehensive system context before writing code.' It uses specific verb+resource and distinguishes itself from siblings like run_python and pip_install.

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

Usage Guidelines4/5

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

Explicitly says 'CALL THIS FIRST,' indicating when to use it. While no alternatives or exclusions are given, the context makes it clear that this is the initial step. Siblings are distinct tools.

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

pip_installA

Pre-install a Python package.

Use this to install packages before execution if you know you'll need them, or if auto-install missed something.

Args: package_name: The pip package name to install

Returns: Installation result

ParametersJSON Schema
NameRequiredDescriptionDefault
package_nameYes

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A3.7/5.0
Behavior2/5

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

No annotations are provided, so the description carries full burden. It mentions 'Installation result' but lacks details on side effects (e.g., environment changes, permissions, failure modes). Minimal behavioral disclosure.

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

Conciseness5/5

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

The description is concise (3 sentences) with a clear structure: purpose, usage guidance, and parameter/return sections. No extraneous content.

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

Completeness3/5

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

For a simple 1-parameter tool with an output schema, the description covers core purpose and usage. However, it omits error handling, return format, and potential prerequisites, leaving gaps for an agent.

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?

With 0% schema description coverage, the description adds basic meaning to 'package_name' as 'The pip package name to install', but does not elaborate on format or version specifics. Adequate but not rich.

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 tool's action ('Pre-install a Python package') and the resource (Python package). It distinguishes from sibling tools like 'run_python' by specifying installation.

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

Usage Guidelines4/5

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

Provides explicit guidance on when to use ('if you know you'll need them, or if auto-install missed something'), but does not mention when not to use or name alternative tools.

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

record_semantic_failureA

Record a semantic failure: when code executed successfully but didn't accomplish the goal.

This is different from error-based learning. Use this when:

  • Code ran without errors but produced wrong output

  • Tool was used but didn't achieve the intended objective

  • An approach worked technically but failed semantically

Args: objective: What you were trying to accomplish failed_approach: What you tried that didn't work (even though it ran) successful_approach: What actually worked to accomplish the objective context: Why the first approach failed or additional context tags: Comma-separated tags (e.g., "api,authentication,retry")

Example: record_semantic_failure( objective="Display image in Goose app", failed_approach="Used print() to output file path", successful_approach="Returned base64 encoded image as MCP content object", context="MCP clients need structured content objects, not just paths", tags="goose,mcp,display,images" )

Returns: Confirmation message

ParametersJSON Schema
NameRequiredDescriptionDefault
objectiveYes
failed_approachYes
successful_approachYes
contextNo
tagsNo

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A4.6/5.0
Behavior4/5

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

No annotations are provided, so the description bears full responsibility. It explains that the tool records semantic failures and returns a confirmation message, which is adequate for a simple recording tool. No contradictions.

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

Conciseness5/5

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

The description is concise and well-structured, with a clear purpose statement, usage conditions, labeled parameters, and a concrete example. No extraneous information.

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

Completeness5/5

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

The description covers purpose, usage guidelines, all parameters with examples, and return value. Given the tool's low complexity and presence of an output schema, it is fully complete for an agent to use correctly.

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

Parameters5/5

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

The schema has no descriptions (0% coverage), but the tool description provides detailed explanations for all five parameters, including examples and defaults, fully compensating for the schema gap.

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 tool's purpose: recording semantic failures when code runs without errors but fails to achieve the goal. It includes examples and distinguishes from error-based learning, making the purpose unambiguous.

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

Usage Guidelines4/5

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

The description explicitly lists three scenarios for using the tool, providing clear context. It does not explicitly mention when not to use it or compare to siblings, but the guidance is sufficient for differentiation.

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

run_pythonA

Execute Python code to accomplish ANY task.

This is a universal tool - write Python to do what you need:

  • HTTP requests (requests, httpx, aiohttp)

  • Parse HTML (beautifulsoup4, lxml)

  • Process data (pandas, json, csv)

  • File operations (pathlib, shutil)

  • System commands (subprocess)

  • Images (Pillow, opencv)

  • And anything else Python can do!

Args: code: Python code to execute. Use print() for output. description: Brief task description (for logging) timeout: Max execution time in seconds auto_install: Auto-install missing packages

Returns: Execution result with stdout, stderr, status, and any generated images

Example: code = ''' import requests resp = requests.get("https://api.github.com/users/octocat") data = resp.json() print(f"User: {data['login']}") print(f"Repos: {data['public_repos']}") '''

ParametersJSON Schema
NameRequiredDescriptionDefault
codeYes
descriptionNo
timeoutNo
auto_installNo

TDQS

A3.8/5.0
Behavior3/5

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

No annotations are provided, so the description must convey behavioral traits. It states that code execution occurs, returns stdout/stderr/status/images, and mentions timeout and auto-install. However, it does not disclose potential security implications, execution environment restrictions, or that any code run could be dangerous. This omission is notable for a tool that runs arbitrary code.

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 well-structured with a summary, bullet list of capabilities, clear Args section, Returns line, and an example. It is front-loaded with the primary purpose. While somewhat lengthy due to the example and extensive list, every part adds value. It could be slightly more concise but remains effective.

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

Completeness3/5

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

Given the tool has 4 parameters, no output schema, and no annotations, the description covers purpose, parameters, return format, and provides an example. However, it lacks usage guidelines, security warnings, and context about when to prefer siblings. It is adequate but not fully complete for a tool of this complexity.

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?

The input schema has 0% description coverage, but the tool description explains each parameter in the Args section: 'code: Python code to execute. Use print() for output.', 'description: Brief task description (for logging)', 'timeout: Max execution time in seconds', 'auto_install: Auto-install missing packages'. This adds meaning beyond the schema's titles and types.

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 tool's purpose: 'Execute Python code to accomplish ANY task.' It lists numerous capabilities (HTTP requests, parsing, data processing, etc.), making the scope unmistakable. The tool name 'run_python' is self-explanatory, and the description reinforces its universality.

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?

The description positions the tool as 'universal' and lists many use cases, but it does not provide guidance on when not to use it or suggest alternative tools. Siblings like 'pip_install' and 'run_python_stream' exist, but no distinctions are made. The description lacks explicit context for appropriate vs. inappropriate usage.

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

run_python_streamA

Execute Python code with REAL-TIME STREAMING OUTPUT.

Perfect for long-running tasks where you want to see progress as it happens:

  • Web scraping multiple pages (see each page as it's scraped)

  • Data processing loops (see progress through large datasets)

  • API calls with retries (see each attempt)

  • File operations (see each file as it's processed)

  • Long computations (see intermediate results)

Output streams in real-time as the code executes, so you see results immediately instead of waiting for the entire execution to complete.

Args: code: Python code to execute. Use print() liberally for progress updates. description: Brief task description (for logging) timeout: Max execution time in seconds auto_install: Auto-install missing packages

Returns: Streaming output followed by execution summary, with any generated images

Example: code = ''' import time for i in range(5): print(f"Processing item {i+1}/5...") time.sleep(1) print("āœ“ Done!") '''

The output will appear line-by-line as the code runs, not all at once at the end.

ParametersJSON Schema
NameRequiredDescriptionDefault
codeYes
descriptionNo
timeoutNo
auto_installNo

TDQS

A4.1/5.0
Behavior4/5

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

With no annotations, the description fully describes the streaming behavior, the role of print statements, and the output format (streaming, summary, images). It provides a concrete example demonstrating real-time output. No critical behavioral traits are missing.

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 well-structured with headers, bullet points, and an example. It is somewhat verbose but every part adds value. The purpose is front-loaded, and the organization aids readability.

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

Completeness4/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 explains the return format clearly. It covers usage patterns, parameter semantics, and provides an example. For a 4-parameter tool with no annotations, it is fairly complete, though a brief note on error behavior would enhance it.

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 0%, so the description must compensate. It explains that 'code' should use print(), 'description' is for logging, 'timeout' is max execution time, and 'auto_install' handles missing packages. However, it does not provide detailed parameter constraints or formats beyond schema types, so value added is moderate.

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 tool executes Python code with real-time streaming output, distinguishing it from siblings like 'run_python' and 'pip_install'. It uses specific verbs and resources, making the purpose unambiguous.

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

Usage Guidelines4/5

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

The description provides multiple use cases (e.g., web scraping, data processing loops) and explains when streaming is beneficial. However, it does not explicitly state when not to use the tool (e.g., for short tasks or non-streaming needs), but the context is clear enough for an AI agent.

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

run_with_retryA

Execute Python code with intelligent retry and error analysis.

On failure, this tool:

  1. Analyzes the error pattern

  2. Searches past learnings (both error-based and semantic) for solutions

  3. Provides diagnostic information

  4. Suggests fixes based on error type and similar objectives

IMPORTANT: Use record_semantic_failure() if code runs successfully but doesn't accomplish the objective. This helps the system learn from non-error failures.

Use this for more robust execution when errors are expected or when learning from previous similar tasks.

Args: code: Python code to execute description: Task description (helps find relevant semantic learnings) max_retries: Max retry attempts (same code) timeout: Execution timeout in seconds

Returns: Detailed execution result with retry info and suggestions from both error and semantic learnings

ParametersJSON Schema
NameRequiredDescriptionDefault
codeYes
descriptionNo
max_retriesNo
timeoutNo

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A4.7/5.0
Behavior5/5

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

No annotations provided, but description fully details the retry mechanism: analyzing errors, searching learnings, providing diagnostics and suggestions. Discloses retry count, timeout, and post-failure analysis. No contradictions.

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?

Well-structured with summary, bullet points, usage note, parameter list, and return description. Minor redundancy ('error and semantic learnings' appears twice) but overall concise for the amount of information.

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

Completeness5/5

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

Covers all aspects: purpose, behavior on failure, parameter explanations, usage guidance, return value. Output schema exists and description appropriately mentions return type. References sibling tools for additional context.

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

Parameters5/5

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

Schema has 0% description coverage, but description adds meaningful explanations for all four parameters: code, description (helps find semantic learnings), max_retries (max retry attempts), timeout (execution timeout). Adds value beyond 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 'Execute Python code with intelligent retry and error analysis.' It specifies the verb and resource, and distinguishes from siblings like run_python (no retry) and run_python_stream (streaming).

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

Usage Guidelines4/5

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

Explicitly says 'Use this for more robust execution when errors are expected or when learning from previous similar tasks.' Also advises using record_semantic_failure for non-error failures, providing clear usage context. Could be slightly more explicit about when not to use.

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

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.

  1. 9 tool updatesv0.2.5
    • First observedadd_learning
    • First observedconfigure
    • First observedget_learnings
    • First observedget_system_context
    • First observedpip_install
    • First observedrecord_semantic_failure
    • First observedrun_python
    • First observedrun_python_stream
    • First observedrun_with_retry

TDQS

A4.2/5.0
Disambiguation5/5

Each tool has a clear and distinct purpose. run_python and run_python_stream are differentiated by streaming vs. non-streaming execution. run_with_retry adds retry logic. Learning tools (add_learning, record_semantic_failure) handle different failure types. configure, get_learnings, get_system_context, and pip_install are all unique and unambiguous.

Naming Consistency5/5

All tool names follow a consistent verb_noun pattern in snake_case, e.g., add_learning, run_python, get_system_context. There are no deviations or mixed conventions.

Tool Count5/5

With 9 tools, the set is well-scoped for a code execution MCP server. It covers execution, learning, configuration, context retrieval, and package management without redundancy or gaps.

Completeness4/5

The tool surface covers core workflows: code execution (with variants), error/semantic learning, configuration, system context, and package installation. Minor gaps exist (e.g., no tool to delete or update learnings), but overall it's nearly complete for the stated purpose.

Maintenance

ActivityInactive
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
    D
    maintenance
    A Model Context Protocol (MCP) server that enables LLMs to run ANY code safely in isolated Docker containers.
    121
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    A comprehensive MCP server enabling LLMs to execute commands, manage files, interact with Figma, search the web, generate images, and more, extending their capabilities beyond text generation.
    Apache 2.0
  • A
    license
    A
    quality
    D
    maintenance
    A production-grade MCP server providing a persistent Python REPL with multi-session support, sandboxing, and timeout protection, enabling LLM agents to execute Python code across multiple turns with variables that persist between calls.
    12
    1
    MIT

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/anaseqal/codemode'

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