Skip to main content

langchain-tokportal

PyPI CI License: MIT

LangChain / LangGraph integration for TokPortal.

TokPortal is the managed social infrastructure API: real TikTok, Instagram and YouTube accounts created, warmed and operated by human account managers in 16+ countries — exposed as a REST API and an MCP server. No OAuth per account, no 25-posts/day cap, no app review.

This package gives your agents two ways to drive TokPortal:

Mode What you get When to use
Native tools (toolkit.get_tools()) 6 hand-written BaseTools wrapping the tokportal Python SDK: credit balance, create bundle, configure video, publish bundle, get bundle, list accounts Simple sync agents, no MCP dependency at runtime
MCP tools (await toolkit.aget_tools("mcp")) Every tool of the remote TokPortal MCP server (90+ operations: uploads, warming, analytics, webhooks, comments, bans…) loaded through langchain-mcp-adapters Full API surface, async agents

Installation

pip install langchain-tokportal
# optional, for the LangGraph example below
pip install langchain langchain-openai

Get an API key at https://app.tokportal.com/developer and export it:

export TOKPORTAL_API_KEY=sk_...

Quick start (native tools)

from langchain_tokportal import TokPortalToolkit

toolkit = TokPortalToolkit.from_api_key()          # reads TOKPORTAL_API_KEY
tools = toolkit.get_tools()

for tool in tools:
    print(tool.name)
# tokportal_get_credit_balance
# tokportal_create_bundle
# tokportal_configure_bundle_video
# tokportal_publish_bundle
# tokportal_get_bundle
# tokportal_list_accounts

print(tools[0].invoke({}))                          # -> {"data": {"balance": ...}}

Every tool returns a JSON string (the raw TokPortal data envelope, or an {"error": {...}} object with status, code, request_id and retryable so the model can self-correct).

LangGraph agent example (langchain.agents.create_agent, LangChain 1.x)

import asyncio

from langchain_openai import ChatOpenAI
from langchain.agents import create_agent

from langchain_tokportal import TokPortalToolkit

SYSTEM = (
    "You operate TokPortal, a managed social infrastructure API. "
    "Always check the credit balance before creating bundles. "
    "A bundle must be published for a human account manager to start working on it."
)


async def main() -> None:
    toolkit = TokPortalToolkit.from_api_key()

    # "native" = 6 SDK tools, "mcp" = full remote MCP tool set, "all" = both
    tools = await toolkit.aget_tools("mcp")

    agent = create_agent(ChatOpenAI(model="gpt-4.1"), tools, system_prompt=SYSTEM)

    result = await agent.ainvoke(
        {
            "messages": [
                (
                    "user",
                    "Order one new TikTok account in the US with 3 video slots and "
                    "advanced warming on the terms 'home workout', 'protein snacks', "
                    "'gym motivation'. Publish it and tell me the bundle id.",
                )
            ]
        }
    )
    print(result["messages"][-1].content)


asyncio.run(main())

Sync-only code paths can call toolkit.get_mcp_tools() (wraps asyncio.run).

Using the MCP connection directly

from langchain_mcp_adapters.client import MultiServerMCPClient
from langchain_tokportal import mcp_connection

client = MultiServerMCPClient({"tokportal": mcp_connection("sk_...")})
tools = await client.get_tools()

mcp_connection() returns a Streamable-HTTP connection dict pointing at https://app.tokportal.com/api/ext/mcp with Authorization: Bearer <api_key>.

Tool reference (native)

Tool REST operation
tokportal_get_credit_balance GET /credits/balance
tokportal_create_bundle POST /bundles
tokportal_configure_bundle_video PUT /bundles/{id}/videos/{position}
tokportal_publish_bundle POST /bundles/{id}/publish
tokportal_get_bundle GET /bundles/{id}
tokportal_list_accounts GET /accounts

Typical flow: get_credit_balancecreate_bundle (draft) → configure_bundle_video × N → publish_bundle → poll get_bundle or subscribe to webhooks.

Resources

License

MIT

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

langchain_tokportal-0.1.0.tar.gz (10.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

langchain_tokportal-0.1.0-py3-none-any.whl (11.1 kB view details)

Uploaded Python 3

File details

Details for the file langchain_tokportal-0.1.0.tar.gz.

File metadata

  • Download URL: langchain_tokportal-0.1.0.tar.gz
  • Upload date:
  • Size: 10.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.12

File hashes

Hashes for langchain_tokportal-0.1.0.tar.gz
Algorithm Hash digest
SHA256 524088a91f676ea7fc3d9e9aa47ff858d2b2cfe8b1e42c0eafc6dfaf5b08dc22
MD5 c8261771fa60014414c59a6bacfd1d36
BLAKE2b-256 dd0b734e5eaf5d34ac4f4cf794d65e7c99a2b69dccbc63d0ce39e1af179248af

See more details on using hashes here.

File details

Details for the file langchain_tokportal-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for langchain_tokportal-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4f737094458caf7e795455d5829c862336f68afe00aa15ac07f231e5149fe829
MD5 a051a18b33773cb5f7bff30a3375a53f
BLAKE2b-256 4117c54750e03d054e5f33909c6c91f33aebee0e9ad2e7e21a0594a50908eb59

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page