Skip to main content

sveda-python-sdk

Python SDK for the Sveda sidecar HTTP API and host MCP integration.

Docs: sveda.dev/docs/hosts/python

PyPI: sveda-python-sdk (import sveda)

Install

pip install sveda-python-sdk

Sidecar client

from sveda import SvedaClient, start_host_session

client = SvedaClient(base_url="http://127.0.0.1:8787", host_api_key="...")
tok = client.embed.create_token(visitor_id="flask-playground")

client = SvedaClient(base_url="http://127.0.0.1:8787", embed_token=tok.token)
for event in client.chat.create_streamed(
    messages=[{"role": "user", "content": "Hi"}],
    chat_id="c1",
):
    print(event.type)

Host MCP integration

Register tools, expose POST /mcp/sveda, and mint MCP credentials when starting an embed session:

import os
from sveda import HostManager, MODE_READ, start_host_session
from sveda.integrations.flask import register_host_mcp

class SearchPostsTool:
    def name(self) -> str:
        return "search_posts"

    def description(self) -> str:
        return "Search posts by title or body."

    def schema(self) -> dict:
        return {"query": {"type": "string", "description": "Search text", "required": True}}

    def mode(self) -> str:
        return MODE_READ

    def domain(self) -> str:
        return "posts"

    def handle(self, arguments: dict, context=None) -> dict:
        return {"success": True, "data": {"posts": []}}


host = HostManager(
    base_url=os.environ["SVEDA_CLIENT_BASE_URL"],
    host_api_key=os.environ["SVEDA_CLIENT_HOST_API_KEY"],
    mcp_path="/mcp/sveda",
    server_name="My App",
    instructions="Tools for the signed-in user.",
)
host.resolve_tools_using(lambda user: [SearchPostsTool()])
host.policy_using(lambda user: "agent")

register_host_mcp(app, host)

@app.post("/sveda/session")
def sveda_session():
    return start_host_session(
        host=host,
        user={"id": "user-1"},
        request_origin=request.host_url.rstrip("/"),
    )

HostManager mints in-memory MCP bearer tokens by default (McpTokenStore). Wire verify_bearer_token_using / mint_token_using when you use your own auth.

Framework helpers:

  • sveda.integrations.flask.register_host_mcp(app, host, path="/mcp/sveda")
  • sveda.integrations.fastapi.create_host_mcp_router(host) — mount with prefix="/mcp/sveda"
  • sveda.integrations.django.host_mcp_view(host)

Lower-level pieces:

  • handle_host_mcp_request(host, body, user=..., headers=...)
  • process_host_mcp_http(host, body=..., headers=...)

Embed token requests include host_mcp_url and host_mcp_token automatically when using HostManager.start_session or start_host_session(host=..., user=..., request_origin=...).

Manual session start:

start_host_session(
    "http://127.0.0.1:8787",
    "host-api-key",
    "flask-playground",
    host_mcp_url="https://app.example.com/mcp/sveda",
    mint_mcp_token=lambda: "your-mcp-bearer-token",
)

Agent introspection

Print the registered tool manifest as JSON (sveda.host/v1):

python -m sveda.describe myapp.sveda_host:sveda_host

HostManager.describe(user=None) returns the same structure programmatically. With a logged-in dev session, playground apps expose GET /sveda/tools.

License

GNU Affero General Public License v3.0. See LICENSE.

Release files for sveda-python-sdk 0.5.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sveda-python-sdk 0.5.4
File Size Uploaded
sveda_python_sdk-0.5.4.tar.gz 30.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for sveda-python-sdk 0.5.4
File Interpreter ABI Platform
sveda_python_sdk-0.5.4-py3-none-any.whl Python 3 none any Details

Total release size: 61.9 kB

Release files / sveda_python_sdk-0.5.4.tar.gz

Download URL sveda_python_sdk-0.5.4.tar.gz
Size 30.4 kB
Tags Source
SHA-256 checksum
How to use checksums
2577689d8313718606822e8d025398121b7d66e465cea36bab71746fa1edf4c5
BLAKE2b-256 checksum
How to use checksums
174efba63040a612af78653ee7f0ca12ae93741be9fdd927ce4f3d558da6ea32
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 22, 2026.

Transparency log

Release files / sveda_python_sdk-0.5.4-py3-none-any.whl

Download URL sveda_python_sdk-0.5.4-py3-none-any.whl
Size 31.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
517d792df5c8d61ca062552daa2e3bafb50c7027a43a3136394bac675fe91ba7
BLAKE2b-256 checksum
How to use checksums
afd7ec2d675102dcaa56618c667ee96b893cacd01756f4f459ac576712e3f25c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 22, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.5.4 This release

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

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