0

Local Toolkits

Local Toolkits explains the tools layer of MTPX with practical guidance for building inspectable, tool-using agents.

Lo
Local Toolkits
Chapter 010Core runtimeToolsIndex
01Orientation

Local Toolkits belongs to the core runtime track. The page breaks the idea into responsibilities, implementation rules, failure modes, and the signals you should expose in a product UI.

Use this when

Use this when you need to understand how local toolkits affects a real MTPX agent before you wire it into an application.

  • What local toolkits owns in the runtime.
  • How it connects to planning, tool execution, events, providers, or storage.
  • What to log, test, and expose to users when this layer is active.
  • Common mistakes that make agent systems hard to inspect.
02 / syntax starter
@Agent.mtp_tool(description="Add two integers.")
def add(a: int, b: int) -> int:
    return a + b

registry.register_toolkit_loader("custom", Agent.toolkit_from_functions("custom", add))
03 / manual

Read the system

The complete source manual—syntax, examples, linked references, edge cases, and implementation notes.

Documentation index ↗

MTP includes local/no-key toolkits inspired by common agent toolkit patterns:

  • calculator
  • file
  • python
  • shell

MTP also includes optional search/web-scrape toolkits inspired by Agno:

  • wikipedia
  • website
  • newspaper
  • newspaper4k
  • crawl4ai

Use them with:

pythonfrom mtp import Agent

registry = Agent.ToolRegistry()
Agent.register_local_toolkits(registry, base_dir=".")

Discovery + lazy loading

  • Tool names are discoverable through loader spec preview.
  • Handlers load only when a matching tool is called.

Toolkit summary

calculator.*

  • calculator.add
  • calculator.subtract
  • calculator.multiply
  • calculator.divide
  • calculator.sqrt

file.*

  • file.list_files
  • file.read_file
  • file.write_file
  • file.search_in_files

Paths are constrained to the configured base_dir.

python.*

  • python.run_code
  • python.run_file

Execution uses isolated subprocess mode (python -I) with timeout. This is a constrained execution helper, not a security sandbox.

The legacy allow_unsafe_exec constructor argument is accepted for compatibility but no longer enables in-process exec.

shell.*

  • shell.run_command

Runs bare command names in base_dir with timeout and an allowlist (echo, pwd, ls, dir by default). Absolute or path-qualified executables are rejected even when their basename is allowlisted. Use allowed_commands= to customize.

Search + web-scrape toolkits

These are dependency-optional and lazily loaded. You can register them without installing packages, but the first call will fail with an install hint if dependencies are missing.

Install all web toolkit dependencies with one command:

bashpip install "mtpx[toolkits-web]"

wikipedia.*

  • wikipedia.search_wikipedia

Dependency:

  • pip install wikipedia

website.*

  • website.read_url

Dependencies:

  • pip install requests beautifulsoup4

WebsiteToolkit accepts only http and https URLs. By default it refuses localhost, private, link-local, multicast, reserved, and unresolved targets to reduce SSRF risk when agents can choose URLs. Use allowed_hosts={...} for a public allowlist, or allow_private_hosts=True only in trusted local workflows.

newspaper.*

  • newspaper.get_article_text

Dependencies:

  • pip install newspaper3k lxml_html_clean

newspaper4k.*

  • newspaper4k.read_article

Dependencies:

  • pip install newspaper4k lxml_html_clean

crawl4ai.*

  • crawl4ai.web_crawler

Dependency:

  • pip install crawl4ai

Risk and policy

Default policy:

  • read-only tools: allow
  • write tools: allow
  • destructive tools: ask

Customize with RiskPolicy when creating ToolRegistry.

Related:

01

Read

Understand where Local Toolkits sits in the agent loop before adding abstractions.

02

Wire

Connect the smallest useful provider, registry, store, or event stream first.

03

Observe

Expose events, logs, results, and failure states while the runtime is still moving.

04

Harden

Add policy, tests, retries, and audit traces after the behavior is visible.

Next docMCP Compatibility Matrix