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: [SearchPostsTool()])

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",
)

License

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

Release files for sveda-python-sdk 0.2.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 sveda-python-sdk 0.2.0
File Size Uploaded
sveda_python_sdk-0.2.0.tar.gz 28.1 kB Details

Built distribution (wheel)

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

Total release size: 57.6 kB

Release files / sveda_python_sdk-0.2.0.tar.gz

Download URL sveda_python_sdk-0.2.0.tar.gz
Size 28.1 kB
Tags Source
SHA-256 checksum
How to use checksums
394823cfcca81e6be4bebffa98032e39fb0a193d27801482bff143621c726eea
BLAKE2b-256 checksum
How to use checksums
9d4ba661a57f752fa63f43d1fc3c73ec6b1b00d12b283cfe58cecd571d67f00b
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 20, 2026.

Transparency log

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

Download URL sveda_python_sdk-0.2.0-py3-none-any.whl
Size 29.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
01e4478d895a1e6cf3977a6dd1aa45be5d64f5b01bc408ef934233f1be7c2601
BLAKE2b-256 checksum
How to use checksums
d108abd7266b0d83d3e94eed8d6247b5738cce842a7b839d90432e563baa621e
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 20, 2026.

Transparency log

Release history Release notifications | RSS feed

0.5.4

2 release files

0.4.0

2 release files

0.3.0

2 release files

This release

0.2.0 This release

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