Skip to main content

langchain-surgemesh

LangChain tools for Surgemesh, agent-first social publishing. Your agent can quote the exact price of a post, schedule it to one or more social channels, check its prepaid credit, and track delivery, all through one API key.

Preview: quotes, channel connects and sandbox posts work today. Sandbox posts are validated against each network's real limits and priced exactly, but never published or charged. Live posting and payments are coming soon.

Install

pip install langchain-surgemesh

Get an API key

curl -X POST https://api.surgemesh.com/v1/signup \
  -H 'content-type: application/json' \
  -d '{"email": "you@example.com", "accept_terms": true}'

The response holds your api_key (shown once). Then:

export SURGEMESH_API_KEY=sm_...

Quick start

from langchain.agents import create_agent
from langchain_surgemesh import SurgemeshToolkit

toolkit = SurgemeshToolkit()            # reads SURGEMESH_API_KEY
agent = create_agent("openai:gpt-4.1", toolkit.get_tools())

agent.invoke({"messages": "List my Surgemesh channels, quote a post for 2026-11-03T15:00:00Z, "
                          "then schedule 'Hello from our agent' to my sandbox channel at that time."})

Tools

Tool What it does Spends credit?
quote_post Exact price for a time and number of channels (or a network mix), plus cheaper nearby times. Returns a quote_id. No
publish_post Schedules a post to channel ids from list_channels. Needs a quote_id from quote_post or an idempotency_key. Yes, at the quoted price
list_channels Channels this key can post to (connected accounts and sandbox test channels). No
get_balance Prepaid credit (credit_usd), plan and sandbox allowance. No
get_post_status Status, price and per-channel delivery state of a post. No

You can also use each tool on its own: SurgemeshQuotePostTool, SurgemeshPublishPostTool, SurgemeshListChannelsTool, SurgemeshGetBalanceTool, SurgemeshGetPostStatusTool. Use the toolkit when you want publish_post to accept a quote_id from quote_post; tools created by one toolkit share their quotes.

Safety rules built in

  • Nothing posts on its own. The tools act only when your agent calls them. Installing the package or building the toolkit makes no requests.
  • Quote first. publish_post refuses to run without a quote_id from quote_post or an explicit idempotency_key. With a quote_id, the quoted price becomes the post's price cap (max_price_usd), so the post is refused rather than charged more.
  • Exactly once. Every publish carries an idempotency key, so a retry never double-posts or double-charges. A quote_id is used for one post.
  • Clear credit errors. If the account lacks prepaid credit, the tool says so plainly (nothing is scheduled or charged) and points to cheaper times or adding credit.

To ask a person before anything is published, put publish_post behind your framework's human-in-the-loop step.

Configuration

Setting Default
api_key / SURGEMESH_API_KEY required for everything except quote_post
base_url / SURGEMESH_BASE_URL https://api.surgemesh.com
toolkit = SurgemeshToolkit.from_api_key(api_key="sm_...", base_url="https://api.surgemesh.com")

Errors raise SurgemeshError (with status, code and hint); InsufficientCreditError and QuoteRequiredError are subclasses. Inside an agent, tools return the error message to the model instead of crashing the run.

Zero-code alternative: the Surgemesh MCP server

Surgemesh is also a remote MCP server (com.surgemesh/surgemesh in the MCP Registry) with the full tool set, including channel connect, onboarding and analytics. With langchain-mcp-adapters:

import os
from langchain_mcp_adapters.client import MultiServerMCPClient
from langchain.agents import create_agent

client = MultiServerMCPClient({
    "surgemesh": {
        "transport": "streamable_http",
        "url": "https://api.surgemesh.com/mcp",
        "headers": {"Authorization": f"Bearer {os.environ['SURGEMESH_API_KEY']}"},
    }
})
tools = await client.get_tools()
agent = create_agent("openai:gpt-4.1", tools)

Use this package when you want a small, typed tool set with the quote-first guard; use MCP when you want every Surgemesh tool.

License

Apache License 2.0. Copyright 2026 Novus Index, LLC. See LICENSE and NOTICE. "Surgemesh" is a trademark of Novus Index, LLC; the license grants no trademark rights (see TRADEMARKS.md in the repository root). Contact: dev@surgemesh.com

Metadata

Release files for langchain-surgemesh 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 langchain-surgemesh 0.1.0
File Size Uploaded Provenance Actions
langchain_surgemesh-0.1.0.tar.gz 13.3 kB With provenance Details for langchain_surgemesh-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for langchain-surgemesh 0.1.0
File Interpreter ABI Platform Actions
langchain_surgemesh-0.1.0-py3-none-any.whl Python 3 none any Details for langchain_surgemesh-0.1.0-py3-none-any.whl

Total release size: 26.4 kB

Release files / langchain_surgemesh-0.1.0.tar.gz

Download URL langchain_surgemesh-0.1.0.tar.gz
Size 13.3 kB
Tags Source
SHA-256 checksum
How to use checksums
09c12495b0bc2db34e1bf3936433ef2bd414f0ead0ea1fe9594fcc6abc507481
BLAKE2b-256 checksum
How to use checksums
d76e3b32753399b02b3cd20aa6b98e42079903c953ce3d7f72a9db6866d21406
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 Oct 31, 2026.

Transparency log

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

Download URL langchain_surgemesh-0.1.0-py3-none-any.whl
Size 13.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
feb87d50f7e4b8f9219610059180d8727b7568a99aae2b1c2543777477601860
BLAKE2b-256 checksum
How to use checksums
e4685c974fbad6381faab8623a7f735099e6a187600dcdedc92b936d53b415d1
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 Oct 31, 2026.

Transparency log

Security for langchain-surgemesh 0.1.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

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for langchain_surgemesh-0.1.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 Oct 31, 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.1.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