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

MIT

Release files for sveda-python-sdk 0.1.1

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.1.1
File Size Uploaded
sveda_python_sdk-0.1.1.tar.gz 16.6 kB Details

Built distribution (wheel)

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

Total release size: 34.9 kB

Release files / sveda_python_sdk-0.1.1.tar.gz

Download URL sveda_python_sdk-0.1.1.tar.gz
Size 16.6 kB
Tags Source
SHA-256 checksum
How to use checksums
2542a23232b8537455cce285eca2c735366863d8f2f95a9f5f81e60c7c3732e3
BLAKE2b-256 checksum
How to use checksums
9de5de6911f302ac3d9f90689ec94dfefc4eb851d53eb8ec73a96f8bc445c76e
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 18, 2026.

Transparency log

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

Download URL sveda_python_sdk-0.1.1-py3-none-any.whl
Size 18.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e1336409e65ea7e51b6d070e7bb48e93f4d9360803bc263f18a59d14db3df4cd
BLAKE2b-256 checksum
How to use checksums
dc8dd408a24d2af7325843dd7db1557e2dddc25653df2755d282f9b9cd72da4a
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 18, 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

0.2.0

2 release files

0.1.2

2 release files

This release

0.1.1 This release

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