Skip to main content

ncp-langgraph

License: Apache-2.0 Python PyPI

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.x on PATH (or pass an absolute path via NCPNode.from_subprocess(binary=...))
  • LangGraph 1.x

v0.1.0 scope and limitations (honest)

  • Sync only. NCPNode exposes a synchronous __call__. Native async support (NCPAsyncNode) is a v0.2.0+ addition.
  • One subprocess per call. Each invocation spawns a fresh ncp-mcp-server process. 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 NCPNode instance. 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

Release files for ncp-langgraph 0.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 ncp-langgraph 0.1.0
File Size Uploaded
ncp_langgraph-0.1.0.tar.gz 35.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ncp-langgraph 0.1.0
File Interpreter ABI Platform
ncp_langgraph-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 62.6 kB

Release files / ncp_langgraph-0.1.0.tar.gz

Download URL ncp_langgraph-0.1.0.tar.gz
Size 35.5 kB
Tags Source
SHA-256 checksum
How to use checksums
5f3b0d41f3ca978f41276084bac4f83d9d30a6514b924c3bd9558bd2a1cbfd09
BLAKE2b-256 checksum
How to use checksums
902c068aee5c1d2a5739e564ada8f99af7bc3d4b682e9025ad2ea0f0c1a5d75b
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 May 29, 2026.

Transparency log

Release files / ncp_langgraph-0.1.0-py3-none-any.whl

Download URL ncp_langgraph-0.1.0-py3-none-any.whl
Size 27.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
312fab386924587897b25940c968895cb2638ae1bf7f451475f9060315181799
BLAKE2b-256 checksum
How to use checksums
2372627eccf32752e70e9bfc1524975619d1029e6938c60b8c2c407845737026
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 May 29, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.0 This release

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