Skip to main content

ltpmcp

LTP (Lean Task Protocol) -- compile LLM goals into deterministic execution plans

Part of the MCP AI Suite.

Features

  • Single-call compilation -- converts a natural-language goal into a structured execution plan with one LLM call
  • Micro-CLI syntax -- compact ~20 tokens/step format (search, fetch, exec, respond) for token efficiency
  • Deterministic runtime -- executes plans step-by-step with variable passing, conditionals, and loops
  • Conditional branching -- ?IF ($var == "value") THEN ... with numeric, string, and contains operators
  • FOREACH iteration -- iterate over list variables with per-item processing
  • ON_FAIL error handling -- retry N times, GOTO fallback step, or terminate with message
  • RE-PLAN -- dynamically recompile the plan mid-execution when results invalidate the approach
  • Parallel execution groups -- concurrent step execution within the same group
  • Type casting -- output variables cast to int, float, list, bool, or json
  • Mermaid visualization -- export plans as Mermaid flowcharts
  • Plan diff -- diff_plans(a, b) structural diff of two plans (added/removed/changed/reordered steps)
  • Library, CLI, MCP & API -- import it, or use the ltpmcp CLI (parse/validate/visualize/diff), the ltpmcp-server MCP server (4 tools: parse_plan, validate_plan, visualize_plan, diff_plans), or the optional ltpmcp-api FastAPI app (/parse, /validate, /visualize, /diff, /compile)

Installation

pip install mcpaisuite-ltpmcp
# Optional extras:
pip install mcpaisuite-ltpmcp[dev]    # Development tools
pip install "mcpaisuite-ltpmcp[api]"  # FastAPI server (ltpmcp-api)

Console scripts: ltpmcp (CLI), ltpmcp-server (MCP, stdio), ltpmcp-api (FastAPI). Runtime deps: pydantic, structlog, click, mcp.

Quick Start

from ltpmcp import LTPCompiler, LTPRuntime

async def my_llm(messages):
    # Your LLM completion function
    return await call_llm(messages)

compiler = LTPCompiler(llm_fn=my_llm)
plan = await compiler.compile("What is the weather in Ibiza?")

runtime = LTPRuntime()
result = await runtime.execute(plan, tool_executor=my_tool_fn, llm_fn=my_llm)
print(result["response"])

Configuration

LTP is configured programmatically via the compiler and runtime constructors. No environment variables are required.

Parameter Description
llm_fn Async callable (messages) -> str for plan compilation and LLM ops
tool_executor Async callable (tool_name, args, namespace) -> dict for tool execution
max_replans Maximum RE-PLAN recompilations allowed (default: 3)

API Reference

LTPCompiler

Compiles a user goal into an LTP plan using one LLM call with Micro-CLI syntax.

compiler = LTPCompiler(llm_fn=my_llm)
plan = await compiler.compile(goal, context="") -> LTPPlan | None  # None on compile failure

LTPRuntime

Deterministic execution engine for LTP plans.

runtime = LTPRuntime(audit_fn=None)
result = await runtime.execute(plan, tool_executor, llm_fn,
                               agent_fn=None, namespace="default",
                               max_replans=3, progress_callback=None) -> dict

LTPPlan / LTPStep

plan.steps         # list[LTPStep]
plan.step_count    # int
plan.variables     # dict[str, Any]
plan.raw           # str -- original Micro-CLI text

Utility Functions

from ltpmcp import validate_plan, plan_to_mermaid, diff_plans

errors = validate_plan(plan)       # list[str] -- validation errors
mermaid = plan_to_mermaid(plan)    # str -- Mermaid diagram
changes = diff_plans(plan_a, plan_b)  # dict -- added/removed/changed/reordered + winner-free summary

Architecture

LTPCompiler sends a single prompt with Micro-CLI syntax examples to the LLM, which returns a compact step-by-step plan. The compiler converts Micro-CLI commands to standard LTP format (with @TOOL references), which is parsed by LTPParser into an LTPPlan AST. LTPRuntime then executes each step sequentially, resolving $variable references with dot-notation support, evaluating conditions, handling FOREACH loops, and routing tool calls through the provided executor.

Testing

pip install -e ".[dev]"
pytest tests/ -v

License

Apache-2.0 — see LICENSE.

Open source for individuals and open-source projects. For commercial use in closed-source products, a commercial license is available — contact contact@mcpaisuite.com.

Release files for mcpaisuite-ltpmcp 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mcpaisuite-ltpmcp 1.1.0
File Size Uploaded
mcpaisuite_ltpmcp-1.1.0.tar.gz 43.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mcpaisuite-ltpmcp 1.1.0
File Interpreter ABI Platform
mcpaisuite_ltpmcp-1.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 90.1 kB

Release files / mcpaisuite_ltpmcp-1.1.0.tar.gz

Download URL mcpaisuite_ltpmcp-1.1.0.tar.gz
Size 43.4 kB
Tags Source
SHA-256 checksum
How to use checksums
d91f445f01d96e8302c7faefc77ea19ecb46d58dfd6a83483b4280dba5ecd479
BLAKE2b-256 checksum
How to use checksums
ccbe319042ab781338be1a4058a390b20c73c6a9900fa088b35239ebd60c0610
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 22, 2026.

Transparency log

Release files / mcpaisuite_ltpmcp-1.1.0-py3-none-any.whl

Download URL mcpaisuite_ltpmcp-1.1.0-py3-none-any.whl
Size 46.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dd40e31d22527f3098389fa64dbacb9dde451424fab58315f8b26bf310852925
BLAKE2b-256 checksum
How to use checksums
ebce40a5cb9c09b3511e4cf7a87a8de4c4c11bd2ae10c259c68ba3ac3dd25e1d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 22, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page