Skip to main content
Glama

execute_code

Destructive

Execute code directly in Jupyter notebooks for debugging, profiling, and temporary calculations without saving to the notebook.

Instructions

Execute code directly in the kernel (not saved to notebook) on the current activated notebook.

Recommended to use in following cases:
1. Execute Jupyter magic commands(e.g., `%timeit`, `%pip install xxx`)
2. Performance profiling and debugging.
3. View intermediate variable values(e.g., `print(xxx)`, `df.head()`)
4. Temporary calculations and quick tests(e.g., `np.mean(df['xxx'])`)
5. Execute Shell commands in Jupyter server(e.g., `!git xxx`)

Under no circumstances should you use this tool to:
1. Import new modules or perform variable assignments that affect subsequent Notebook execution
2. Execute dangerous code that may harm the Jupyter server or the user's data without permission

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYesCode to execute (supports magic commands with %, shell commands with !)
timeoutNoExecution timeout in seconds

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYesList of outputs from the executed code
Behavior4/5

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

Annotations provide destructiveHint=true, indicating potential harm. The description adds valuable context beyond annotations by specifying that code is 'not saved to notebook' (clarifying ephemeral nature), listing dangerous actions to avoid (e.g., harming server), and mentioning support for magic/shell commands. It does not contradict annotations but enriches behavioral understanding with practical constraints and risks.

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 appropriately sized and front-loaded, starting with the core purpose, followed by bullet-pointed usage cases and exclusions. Every sentence earns its place by providing clear, actionable information without redundancy, making it efficient and well-structured for quick comprehension.

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 tool's complexity (destructive, code execution), rich annotations (destructiveHint), and the presence of an output schema, the description is complete enough. It covers purpose, usage guidelines, behavioral context, and risks, addressing key aspects without needing to explain return values (handled by output schema). This provides a comprehensive understanding for safe and effective use.

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 description coverage is 100%, with parameters 'code' and 'timeout' fully documented in the schema. The description adds minimal parameter semantics beyond the schema, only implying code supports magic/shell commands in usage examples. Since the schema does the heavy lifting, the baseline score of 3 is appropriate, as the description provides some but not extensive additional meaning.

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 'Execute code directly in the kernel (not saved to notebook) on the current activated notebook,' specifying the verb ('execute'), resource ('code'), and scope ('directly in the kernel, not saved to notebook'). It distinguishes from siblings like execute_cell (which likely saves to notebook) and insert_execute_code_cell (which inserts a cell), making the purpose specific and differentiated.

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

Usage Guidelines5/5

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

The description provides explicit usage guidelines with 'Recommended to use in following cases' listing 5 scenarios (e.g., magic commands, profiling) and 'Under no circumstances should you use this tool to' listing 2 exclusions (e.g., import modules affecting notebook). This clearly defines when to use this tool versus alternatives, offering both positive and negative guidance.

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/datalayer/jupyter-mcp-server'

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