Metadata-Version: 2.5
Name: vespper
Version: 0.1.0
Summary: Official Python SDK for Vespper document sessions and MCP tools.
Project-URL: Homepage, https://github.com/vespperhq/sdks
Project-URL: Issues, https://github.com/vespperhq/sdks/issues
Project-URL: Repository, https://github.com/vespperhq/sdks.git
Author-email: Vespper <dudu@vespper.com>
License: MIT License
        
        Copyright (c) 2026 Vespper
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Keywords: docx,mcp,model-context-protocol,vespper
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Typing :: Typed
Requires-Python: >=3.10
Requires-Dist: httpx<1,>=0.27
Requires-Dist: pydantic<3,>=2.12
Description-Content-Type: text/markdown

# 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

```python
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

```python
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())
```
