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.2

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.2
File Size Uploaded
sveda_python_sdk-0.1.2.tar.gz 16.7 kB Details

Built distribution (wheel)

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

Total release size: 35.0 kB

Release files / sveda_python_sdk-0.1.2.tar.gz

Download URL sveda_python_sdk-0.1.2.tar.gz
Size 16.7 kB
Tags Source
SHA-256 checksum
How to use checksums
c42596200b93844b8cd5f8a795c8e66efd1bd7738da22d60f20abc29907606c0
BLAKE2b-256 checksum
How to use checksums
4fba8a95443cbb99a4548b57a5a45e97eb6f024592302712dd3ab9be95b50012
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.1.2-py3-none-any.whl

Download URL sveda_python_sdk-0.1.2-py3-none-any.whl
Size 18.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0cdfbd8f623f240e10efd8030da345cdf5d2f4e8fc19cc8d78e85b01a5521c73
BLAKE2b-256 checksum
How to use checksums
d59cfa362d345cceb9b56dc6ceca91806b7db1ef8e81b7ec14574fe9c2d12a9b
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

0.2.0

2 release files

This release

0.1.2 This release

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