LangGraph adapter for NCP: invoke NCP graphs as LangGraph nodes via ncp-mcp-server subprocess.
Project description
ncp-langgraph
LangGraph adapter for the Neural Computation Protocol (NCP).
ncp-langgraph lets you wrap any NCP graph as a LangGraph node:
NCPNode.from_subprocess(...) returns a callable instance that spawns
ncp-mcp-server over stdio, performs the locked MCP dialog, and
returns a partial state-update dict ready for LangGraph to merge.
One NCP graph = one LangGraph node. No glue code, no protocol-buffer plumbing, no PyO3 (in v0.1.0).
Quick start
from typing import Any, TypedDict
from langgraph.graph import END, START, StateGraph
from ncp_langgraph import NCPNode
class State(TypedDict, total=False):
company_url: str
qualification: dict[str, Any]
ncp_trace: dict[str, Any]
qualify_lead = NCPNode.from_subprocess(
graph="/abs/path/to/lead-qualification.yaml",
brick_dir="/abs/path/to/bricks",
output_key="qualification",
timeout=30.0,
)
builder = StateGraph(State)
builder.add_node("qualify_lead", qualify_lead)
builder.add_edge(START, "qualify_lead")
builder.add_edge("qualify_lead", END)
compiled = builder.compile()
result = compiled.invoke({"company_url": "https://example.com"})
# result["qualification"] -- the NCP graph's output_json
# result["ncp_trace"] -- {"result_type", "trace_id", "trace_path"}
For a runnable end-to-end example using the bundled echo-pipeline
graph (stub until issue #29
ships the real lead-qualification graph), see
examples/langgraph/.
Install
1. The NCP MCP adapter binary
cargo install ncp-mcp-server --version 0.1.0 --locked
The version is pinned to keep ncp-langgraph v0.1.x reproducible
against a known ncp-mcp-server release.
2. The Python adapter (this package)
python -m pip install ncp-langgraph
Or pin to a specific version for reproducibility:
python -m pip install ncp-langgraph==0.1.0
ncp-langgraph does NOT bundle the ncp-mcp-server binary in v0.1.0.
The binary is distributed separately as the Rust crate
ncp-mcp-server; install it independently and keep it on PATH, or
pass its absolute path via NCPNode.from_subprocess(binary=...).
Requirements
- Python 3.10+
ncp-mcp-server v0.1.xonPATH(or pass an absolute path viaNCPNode.from_subprocess(binary=...))- LangGraph 1.x
v0.1.0 scope and limitations (honest)
- Sync only.
NCPNodeexposes a synchronous__call__. Native async support (NCPAsyncNode) is a v0.2.0+ addition. - One subprocess per call. Each invocation spawns a fresh
ncp-mcp-serverprocess. No persistent pool. Negligible cost for typical agent workflows; significant for hot-loop / per-token use. Persistent pool is a v0.2.0+ perf optimization. - One graph per
NCPNodeinstance. Multi-graph adapter instances are a v0.2.0+ addition. - Subprocess invocation only. PyO3 direct binding and Streamable
HTTP transport are deferred (see
docs/LANGGRAPH_ADAPTER.md§11 and future-work issue #34 for Streamable HTTP).
License
Apache-2.0. See LICENSE and NOTICE.
Links
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 ncp_langgraph-0.1.0.tar.gz.
File metadata
- Download URL: ncp_langgraph-0.1.0.tar.gz
- Upload date:
- Size: 35.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5f3b0d41f3ca978f41276084bac4f83d9d30a6514b924c3bd9558bd2a1cbfd09
|
|
| MD5 |
7536e7fa6b5d4620a9c35824ba4fd515
|
|
| BLAKE2b-256 |
902c068aee5c1d2a5739e564ada8f99af7bc3d4b682e9025ad2ea0f0c1a5d75b
|
Provenance
The following attestation bundles were made for ncp_langgraph-0.1.0.tar.gz:
Publisher:
publish-langgraph.yml on madeinplutofabio/neural-computation-protocol
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ncp_langgraph-0.1.0.tar.gz -
Subject digest:
5f3b0d41f3ca978f41276084bac4f83d9d30a6514b924c3bd9558bd2a1cbfd09 - Sigstore transparency entry: 1670743219
- Sigstore integration time:
-
Permalink:
madeinplutofabio/neural-computation-protocol@f4eba9140f60f64d2719750c429e4ded7bfa0265 -
Branch / Tag:
refs/tags/ncp-langgraph-v0.1.0 - Owner: https://github.com/madeinplutofabio
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-langgraph.yml@f4eba9140f60f64d2719750c429e4ded7bfa0265 -
Trigger Event:
push
-
Statement type:
File details
Details for the file ncp_langgraph-0.1.0-py3-none-any.whl.
File metadata
- Download URL: ncp_langgraph-0.1.0-py3-none-any.whl
- Upload date:
- Size: 27.1 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 |
312fab386924587897b25940c968895cb2638ae1bf7f451475f9060315181799
|
|
| MD5 |
1bbab6a3d58c7421dc727f8472081b25
|
|
| BLAKE2b-256 |
2372627eccf32752e70e9bfc1524975619d1029e6938c60b8c2c407845737026
|
Provenance
The following attestation bundles were made for ncp_langgraph-0.1.0-py3-none-any.whl:
Publisher:
publish-langgraph.yml on madeinplutofabio/neural-computation-protocol
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ncp_langgraph-0.1.0-py3-none-any.whl -
Subject digest:
312fab386924587897b25940c968895cb2638ae1bf7f451475f9060315181799 - Sigstore transparency entry: 1670743364
- Sigstore integration time:
-
Permalink:
madeinplutofabio/neural-computation-protocol@f4eba9140f60f64d2719750c429e4ded7bfa0265 -
Branch / Tag:
refs/tags/ncp-langgraph-v0.1.0 - Owner: https://github.com/madeinplutofabio
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-langgraph.yml@f4eba9140f60f64d2719750c429e4ded7bfa0265 -
Trigger Event:
push
-
Statement type: