File size: 603 Bytes
ceaf2e8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
from mcp.server.fastmcp import FastMCP
from fastapi import FastAPI
from smoldocling.cli import process_files
import json

# app = FastAPI()
mcp = FastMCP("Smoldocling Document Extractor")

@mcp.tool()
def extract_document(file_path: str) -> dict:
    """
    Extract text and structure from a document at the given file path.
    Returns a dictionary with the extracted document information as JSON.
    """
    result = process_files([file_path], output_dir=None, output_format="json", verbose=False)
    return result

# app.mount("/mcp", mcp)
if __name__ == "__main__":
    mcp.run(transport='stdio')