Skip to main content
Glama

run_python

Execute Python code in a persistent IPython kernel, sharing variables and state across cells. Control execution with directives for wait time and full output.

Instructions

向持久 IPython kernel 提交一个原始 Python cell。

请你使用 IPython 的思想来优雅使用本系列工具。

输入

接受一段 loommux IPython cell 源码。普通 Python 文本使用默认策略;若作者 需要声明本次 cell 的观察策略,使用位于物理行首的 # loommux: 控制 注释。变量、导入和其他 namespace 状态会与同一服务器会话中的后续 cell 共享。

等待上限

本次调用默认最多等待 10 秒。# loommux:--wait 正有限十进制 值只覆盖本次调用的等待上限::

# loommux: --wait 120
build_report()

# loommux: --wait 120# loommux: --full-output 可写在同一条 或不同的控制注释中。重复选项、未知选项、缺少值或非正值会返回 invalid_loommux_directive,不会分配 execution 或提交 kernel。等待 到期不会中断仍在运行的 cell;directive 不改变 Python runtime 或后续 调用的等待上限。

完整输出

若任一有效 # loommux: 控制注释包含 --full-output,该 execution 在终态时直接交付完整 combined 正文,不受默认 300 行交付阈值限制::

# loommux: --full-output
print("\n".join(generate_manifest()))

--wait--full-output 可以组合为 # loommux: --wait 120 --full-output。这些选项只作用于本次 execution,且 authored directive line 保留在原始 source 中。在明确需要 完整阅读某些信息,例如阅读某些文件、资料时,使用该选项避免无意义的 反复阅读开销。

图像展示

IPython display() 产生的 PNG、JPEG、WEBP 或单帧 GIF 图像会按输出 顺序直接交付给agent。普通 display(image) 使用高视觉细节;本次展示 需要整体确认或密集文字时,分别书写 display(image, metadata={"detail": "low"})display(image, metadata={"detail": "original"})detail 只作用于这一处 display() 调用。

执行编号与后续操作

已接受的提交会分配一个正整数 execution,它在服务器进程存续 期间严格递增。若执行仍在运行,或未标记 execution 的 combined 输出 超过 300 行,响应不携带完整输出正文;使用 wait_python 等待,使用 python_execution_status 查看状态,使用 read_python_outputsearch_python_output 读取或搜索保留的输出。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
freeformYes要提交的原始 Python cell 源码文本;可用 ``# loommux:`` 控制注释声明本次初始等待与完整输出策略。
Behavior5/5

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

No annotations are provided, so the description fully carries the behavioral disclosure burden. It reveals key behaviors: default 10-second wait timeout, the use of # loommux: directives, handling of full output and truncation, image display, execution ID assignment, and error responses for invalid directives. It is comprehensive and 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?

The description is well-structured with clearly labeled sections (输入, 等待上限, 完整输出, etc.), front-loaded with the purpose, and every sentence contributes necessary information. It is appropriately sized for the complexity of the tool, with no wasted text.

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 the moderate complexity (1 parameter, no output schema), the description covers input format, directives, default behaviors, error handling, follow-up tools, and output truncation. It provides a complete understanding of how the tool functions and what to expect, making it self-sufficient for an AI agent.

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?

There is only one parameter 'freeform' with 100% schema description coverage, establishing a baseline of 3. The tool description adds significant value beyond the schema by explaining how to embed # loommux: directives for controlling wait and output behavior, thus enriching the meaning of the parameter.

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 starts with a clear statement: '向持久 IPython kernel 提交一个原始 Python cell.' It specifies the verb (submit) and resource (raw Python cell to persistent IPython kernel), distinguishing it from siblings like wait_python or read_python_output which handle follow-up actions.

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 tells when to use sibling tools: '使用 wait_python 等待,使用 python_execution_status 查看状态,使用 read_python_output 或 search_python_output 读取或搜索保留的输出.' It does not mention interrupt_python as an alternative, which is a minor gap, but overall provides clear context on when to use this tool vs others.

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

Install Server

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/MichengLiang/loommux'

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