LTP (Lean Task Protocol) — compile LLM goals into deterministic execution plans
Project description
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
- Library, CLI & MCP server -- import it, or use the
ltpmcpCLI (parse/validate/visualize), theltpmcp-serverMCP server (3 tools:parse_plan,validate_plan,visualize_plan), or the optionalltpmcp-apiFastAPI app
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
errors = validate_plan(plan) # list[str] -- validation errors
mermaid = plan_to_mermaid(plan) # str -- Mermaid diagram
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
AGPL-3.0 — see LICENSE.
Open source for individuals and open-source projects. For commercial use in closed-source products, a commercial license is available — contact gaeldev@gmail.com.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mcpaisuite_ltpmcp-1.0.3.tar.gz.
File metadata
- Download URL: mcpaisuite_ltpmcp-1.0.3.tar.gz
- Upload date:
- Size: 49.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c4a6a35b141b214a1dd087d01533b06ea3df27c1c940829f3b82e5b4271e6ac0
|
|
| MD5 |
52c9939bc7239916aa3240d258df10dc
|
|
| BLAKE2b-256 |
d3b0176c50361a892dc397006aa6684d4fad1a61b03dafacdc2141bb19d7271d
|
Provenance
The following attestation bundles were made for mcpaisuite_ltpmcp-1.0.3.tar.gz:
Publisher:
release.yml on gashel01/ltpmcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mcpaisuite_ltpmcp-1.0.3.tar.gz -
Subject digest:
c4a6a35b141b214a1dd087d01533b06ea3df27c1c940829f3b82e5b4271e6ac0 - Sigstore transparency entry: 1841152533
- Sigstore integration time:
-
Permalink:
gashel01/ltpmcp@6fef75317f28c4a1dce411ef41a4ce076a723de5 -
Branch / Tag:
refs/tags/v1.0.3 - Owner: https://github.com/gashel01
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@6fef75317f28c4a1dce411ef41a4ce076a723de5 -
Trigger Event:
push
-
Statement type:
File details
Details for the file mcpaisuite_ltpmcp-1.0.3-py3-none-any.whl.
File metadata
- Download URL: mcpaisuite_ltpmcp-1.0.3-py3-none-any.whl
- Upload date:
- Size: 52.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ed9208b57698084c87fa5eef35b68cdaf2b3b12b08a0bf5c37b48122952d9041
|
|
| MD5 |
05943381ed35505df7945ac06b91b683
|
|
| BLAKE2b-256 |
1dfc2e158db3cbc66c107480f84a90dc80b00336440acf5fec9dacf4122b8aa7
|
Provenance
The following attestation bundles were made for mcpaisuite_ltpmcp-1.0.3-py3-none-any.whl:
Publisher:
release.yml on gashel01/ltpmcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mcpaisuite_ltpmcp-1.0.3-py3-none-any.whl -
Subject digest:
ed9208b57698084c87fa5eef35b68cdaf2b3b12b08a0bf5c37b48122952d9041 - Sigstore transparency entry: 1841152547
- Sigstore integration time:
-
Permalink:
gashel01/ltpmcp@6fef75317f28c4a1dce411ef41a4ce076a723de5 -
Branch / Tag:
refs/tags/v1.0.3 - Owner: https://github.com/gashel01
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@6fef75317f28c4a1dce411ef41a4ce076a723de5 -
Trigger Event:
push
-
Statement type: