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.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 vespper 0.1.1
File Size Uploaded
vespper-0.1.1.tar.gz 77.8 kB Details

Built distribution (wheel)

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

Total release size: 93.0 kB

Release files / vespper-0.1.1.tar.gz

Download URL vespper-0.1.1.tar.gz
Size 77.8 kB
Tags Source
SHA-256 checksum
How to use checksums
7b0e65d5dd8964866714cb8a34dc006dff73d09e03132fa25e92006a53eac27a
BLAKE2b-256 checksum
How to use checksums
8c9e9628b8ab63e6c9e17a5f683fbc8b73d2ee456784caa3a701f492a63a0f63
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.1-py3-none-any.whl

Download URL vespper-0.1.1-py3-none-any.whl
Size 15.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a964638ebf230f797a2433670f90a11a2092a40dbae26149fe05c53be3f4e900
BLAKE2b-256 checksum
How to use checksums
26c6a017c1e5d2c246c5daa0502ff69b442dd779d3b2b17789fa9644faadd16e
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

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