Spaces:
Running
Running
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()) |