File size: 987 Bytes
ceaf2e8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import asyncio
from mcp import ClientSession, StdioServerParameters
from mcp.client.stdio import stdio_client
import os

async def main():
    # Start the server using the same command as before
    server_params = StdioServerParameters(
        command="python",
        args=["smoldocling/server.py"],
        env=os.environ.copy(),
    )

    async with stdio_client(server_params) as (read, write):
        async with ClientSession(read, write) as session:
            # Initialize the connection
            await session.initialize()

            # List available tools
            tools = await session.list_tools()
            print("[DEBUG] Available tools:", tools)

            # Call the extract_document tool
            result = await session.call_tool(
                "extract_document",
                arguments={"file_path": "input/p2.png"}
            )
            print("[DEBUG] extract_document result:", result)

if __name__ == "__main__":
    asyncio.run(main())