Skip to main content

Vespper Python SDK

Open a Vespper document session and patch a supported MCP client so its normal tool APIs automatically carry Vespper metadata and retain updated DOCX bytes.

OpenAI Agents SDK

import asyncio
from pathlib import Path

from agents import Agent, Runner
from agents.mcp import MCPServerStreamableHttp
from vespper import Vespper


async def main() -> None:
    client = Vespper()
    session_id = await client.open_session("sample.docx")
    mcp = MCPServerStreamableHttp(
        name="Vespper DOCX",
        params={
            "url": client.mcp_url,
            "headers": {"Authorization": client.authorization_header},
        },
        cache_tools_list=True,
    )

    try:
        async with mcp:
            await client.patch_mcp_tools(
                mcp=mcp,
                session_id=session_id,
            )
            agent = Agent(
                name="DOCX Editor",
                instructions=(
                    "Use the available tools to read and edit the loaded document."
                ),
                model="gpt-5.5",
                mcp_servers=[mcp],
            )
            await Runner.run(agent, "Append the word hello to the document.")

        Path("sample-redlined.docx").write_bytes(
            client.get_session_document(session_id)
        )
    finally:
        await client.close_session(session_id)
        await client.close()


asyncio.run(main())

Native MCP and OpenAI

import asyncio
import json
from pathlib import Path

from mcp import ClientSession
from mcp.client.streamable_http import streamablehttp_client
from openai import OpenAI
from vespper import Vespper


async def main() -> None:
    vespper = Vespper()
    openai = OpenAI()
    session_id = await vespper.open_session("sample.docx")

    try:
        async with streamablehttp_client(
            vespper.mcp_url,
            headers={"Authorization": vespper.authorization_header},
        ) as (read, write, _):
            async with ClientSession(read, write) as mcp:
                await mcp.initialize()
                await vespper.patch_mcp_tools(
                    mcp=mcp,
                    session_id=session_id,
                )
                listed = await mcp.list_tools()
                tools = [
                    {
                        "type": "function",
                        "name": tool.name,
                        "description": tool.description,
                        "parameters": tool.inputSchema,
                    }
                    for tool in listed.tools
                ]
                input = [
                    {
                        "role": "user",
                        "content": "Append the word hello to the document.",
                    }
                ]

                for _step in range(6):
                    response = openai.responses.create(
                        model="gpt-5.5",
                        instructions=(
                            "Use the available tools to read and edit the loaded "
                            "document."
                        ),
                        tools=tools,
                        input=input,
                    )
                    input.extend(response.output)
                    calls = [
                        item for item in response.output if item.type == "function_call"
                    ]
                    if not calls:
                        break

                    for call in calls:
                        result = await mcp.call_tool(
                            call.name,
                            json.loads(call.arguments),
                        )
                        data = result.structuredContent or {}
                        input.append(
                            {
                                "type": "function_call_output",
                                "call_id": call.call_id,
                                "output": (
                                    data.get("message")
                                    if call.name == "edit_document"
                                    else json.dumps(data)
                                ),
                            }
                        )

        Path("sample-redlined.docx").write_bytes(
            vespper.get_session_document(session_id)
        )
    finally:
        await vespper.close_session(session_id)
        await vespper.close()


asyncio.run(main())

Release files for vespper 0.1.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 vespper 0.1.0
File Size Uploaded
vespper-0.1.0.tar.gz 77.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for vespper 0.1.0
File Interpreter ABI Platform
vespper-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 92.7 kB

Release files / vespper-0.1.0.tar.gz

Download URL vespper-0.1.0.tar.gz
Size 77.5 kB
Tags Source
SHA-256 checksum
How to use checksums
da52ca7120b2b3ae3680bc0daea37ccaa01c817094d31b2a71dae84f27a28b4c
BLAKE2b-256 checksum
How to use checksums
58c56638d30a51bebcf0386492497d0ae97fb9f34b4785aee0c8285c34ea1478
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 24, 2026.

Transparency log

Release files / vespper-0.1.0-py3-none-any.whl

Download URL vespper-0.1.0-py3-none-any.whl
Size 15.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
402a2b8d759c22ee784fe7ccb1dd63385751c56abb0ff7b4919c4606ef207c22
BLAKE2b-256 checksum
How to use checksums
cba5b616c0c98a501777f22f352333085f6e909efcfc4e1e5307cd8aeb059ccd
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 24, 2026.

Transparency log

Release history Release notifications | RSS feed

0.1.1

2 release files

This release

0.1.0 This release

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