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.

Metadata

Release files for ncp-langgraph 0.4.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.4.0
File Size Uploaded Provenance Actions
ncp_langgraph-0.4.0.tar.gz 35.8 kB With provenance Details for ncp_langgraph-0.4.0.tar.gz

Built distribution (wheel)

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

Total release size: 62.9 kB

Release files / ncp_langgraph-0.4.0.tar.gz

Download URL ncp_langgraph-0.4.0.tar.gz
Size 35.8 kB
Tags Source
SHA-256 checksum
How to use checksums
1f006785664bc7d4a6137b3edb970e36784757ab342e504e19d9d30079749f40
BLAKE2b-256 checksum
How to use checksums
0eb1446b0213828a2034785863977c44d87579160f074aa2d970e675c9ff4864
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 6, 2026.

Transparency log

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

Download URL ncp_langgraph-0.4.0-py3-none-any.whl
Size 27.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b7855d5db3a8b933db5171b89616ed77e9a82f9ac01252c848ca7d1da557b97f
BLAKE2b-256 checksum
How to use checksums
448cdf16b69268bfa34053405bf5854dc4ad0aa62089890bed59c3dff356e51b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 6, 2026.

Transparency log

Security for ncp-langgraph 0.4.0

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for ncp_langgraph-0.4.0.tar.gz

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 Nov 6, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.4.0 This release

2 release files Full provenance

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