pdfco-mcp 0.0.3__py3-none-any.whl → 0.0.5__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,13 +4,27 @@ from pdfco.mcp.models import BaseResponse, ConversionParams
4
4
 
5
5
  from pydantic import Field
6
6
 
7
+
7
8
  @mcp.tool()
8
9
  async def pdf_info_reader(
9
- url: str = Field(description="URL to the source PDF file. Supports publicly accessible links including Google Drive, Dropbox, PDF.co Built-In Files Storage. Use 'upload_file' tool to upload local files."),
10
- httpusername: str = Field(description="HTTP auth user name if required to access source url. (Optional)", default=""),
11
- httppassword: str = Field(description="HTTP auth password if required to access source url. (Optional)", default=""),
12
- password: str = Field(description="Password of the PDF file. (Optional)", default=""),
13
- api_key: str = Field(description="PDF.co API key. If not provided, will use X_API_KEY environment variable. (Optional)", default=None),
10
+ url: str = Field(
11
+ description="URL to the source PDF file. Supports publicly accessible links including Google Drive, Dropbox, PDF.co Built-In Files Storage. Use 'upload_file' tool to upload local files."
12
+ ),
13
+ httpusername: str = Field(
14
+ description="HTTP auth user name if required to access source url. (Optional)",
15
+ default="",
16
+ ),
17
+ httppassword: str = Field(
18
+ description="HTTP auth password if required to access source url. (Optional)",
19
+ default="",
20
+ ),
21
+ password: str = Field(
22
+ description="Password of the PDF file. (Optional)", default=""
23
+ ),
24
+ api_key: str = Field(
25
+ description="PDF.co API key. If not provided, will use X_API_KEY environment variable. (Optional)",
26
+ default=None,
27
+ ),
14
28
  ) -> BaseResponse:
15
29
  """
16
30
  Get detailed information about a PDF document - number of pages, metadata, security, form fields, and more.
@@ -22,5 +36,5 @@ async def pdf_info_reader(
22
36
  httppassword=httppassword,
23
37
  password=password,
24
38
  )
25
-
26
- return await get_pdf_info(params, api_key=api_key)
39
+
40
+ return await get_pdf_info(params, api_key=api_key)
@@ -8,42 +8,72 @@ from typing import List, Any
8
8
 
9
9
  @mcp.tool()
10
10
  async def pdf_add_annotations_images_fields(
11
- url: str = Field(description="URL to the source PDF file. Supports publicly accessible links including Google Drive, Dropbox, PDF.co Built-In Files Storage. Use 'upload_file' tool to upload local files."),
12
- httpusername: str = Field(description="HTTP auth user name if required to access source url. (Optional)", default=""),
13
- httppassword: str = Field(description="HTTP auth password if required to access source url. (Optional)", default=""),
14
- password: str = Field(description="Password for the PDF file. (Optional)", default=""),
15
- name: str = Field(description="File name for the generated output. (Optional)", default=""),
16
- annotations: List[Any] = Field(description="Array of annotation objects to add text, links, shapes, etc. Each object can have: 'text' (string), 'x' (number), 'y' (number), 'size' (number), 'pages' (string), 'color' (string hex), 'link' (string URL), 'fontName' (string), 'fontItalic' (boolean), 'fontBold' (boolean), 'fontStrikeout' (boolean), 'fontUnderline' (boolean). (Optional)", default=[]),
17
- images: List[Any] = Field(description="Array of image objects to add images to PDF. Each object can have: 'url' (string), 'x' (number), 'y' (number), 'width' (number), 'height' (number), 'pages' (string). (Optional)", default=[]),
18
- fields: List[Any] = Field(description="Array of form field objects to fill PDF form fields. Each object can have: 'fieldName' (string), 'pages' (string), 'text' (string), 'fontName' (string), 'size' (number), 'fontBold' (boolean), 'fontItalic' (boolean), 'fontStrikeout' (boolean), 'fontUnderline' (boolean). (Optional)", default=[]),
19
- expiration: int = Field(description="Set the expiration time for the output link in minutes. After this specified duration, any generated output file(s) will be automatically deleted. (Optional)", default=60),
11
+ url: str = Field(
12
+ description="URL to the source PDF file. Supports publicly accessible links including Google Drive, Dropbox, PDF.co Built-In Files Storage. Use 'upload_file' tool to upload local files."
13
+ ),
14
+ httpusername: str = Field(
15
+ description="HTTP auth user name if required to access source url. (Optional)",
16
+ default="",
17
+ ),
18
+ httppassword: str = Field(
19
+ description="HTTP auth password if required to access source url. (Optional)",
20
+ default="",
21
+ ),
22
+ password: str = Field(
23
+ description="Password for the PDF file. (Optional)", default=""
24
+ ),
25
+ name: str = Field(
26
+ description="File name for the generated output. (Optional)", default=""
27
+ ),
28
+ annotations: List[Any] = Field(
29
+ description="Array of annotation objects to add text, links, shapes, etc. Each object can have: 'text' (string), 'x' (number), 'y' (number), 'size' (number), 'pages' (string), 'color' (string hex), 'link' (string URL), 'fontName' (string), 'fontItalic' (boolean), 'fontBold' (boolean), 'fontStrikeout' (boolean), 'fontUnderline' (boolean). (Optional)",
30
+ default=[],
31
+ ),
32
+ images: List[Any] = Field(
33
+ description="Array of image objects to add images to PDF. Each object can have: 'url' (string), 'x' (number), 'y' (number), 'width' (number), 'height' (number), 'pages' (string). (Optional)",
34
+ default=[],
35
+ ),
36
+ fields: List[Any] = Field(
37
+ description="Array of form field objects to fill PDF form fields. Each object can have: 'fieldName' (string), 'pages' (string), 'text' (string), 'fontName' (string), 'size' (number), 'fontBold' (boolean), 'fontItalic' (boolean), 'fontStrikeout' (boolean), 'fontUnderline' (boolean). (Optional)",
38
+ default=[],
39
+ ),
40
+ expiration: int = Field(
41
+ description="Set the expiration time for the output link in minutes. After this specified duration, any generated output file(s) will be automatically deleted. (Optional)",
42
+ default=60,
43
+ ),
20
44
  encrypt: bool = Field(description="Encrypt output file. (Optional)", default=False),
21
- flatten: bool = Field(description="Flatten filled form fields and annotations into PDF content. Set to true to disable editing of filled form fields in the output PDF. (Optional)", default=False),
22
- api_key: str = Field(description="PDF.co API key. If not provided, will use X_API_KEY environment variable. (Optional)", default=None),
45
+ flatten: bool = Field(
46
+ description="Flatten filled form fields and annotations into PDF content. Set to true to disable editing of filled form fields in the output PDF. (Optional)",
47
+ default=False,
48
+ ),
49
+ api_key: str = Field(
50
+ description="PDF.co API key. If not provided, will use X_API_KEY environment variable. (Optional)",
51
+ default=None,
52
+ ),
23
53
  ) -> BaseResponse:
24
54
  """
25
55
  Add text, images, forms, other PDFs, fill forms, links to external sites and external PDF files. You can update or modify PDF and scanned PDF files.
26
-
56
+
27
57
  This tool supports three main ways to add content:
28
-
58
+
29
59
  1. **annotations**: Add text, links, shapes, etc.
30
60
  Properties: text, x, y, size, pages, color, link, fontName, fontItalic, fontBold, fontStrikeout, fontUnderline
31
-
32
- 2. **images**: Add images or other PDF content
61
+
62
+ 2. **images**: Add images or other PDF content
33
63
  Properties: url, x, y, width, height, pages
34
-
64
+
35
65
  3. **fields**: Fill existing form fields
36
66
  Properties: fieldName, pages, text, fontName, size, fontBold, fontItalic, fontStrikeout, fontUnderline
37
-
67
+
38
68
  Example annotations:
39
69
  [{"text": "Sample Text - Click here to test link", "x": 250, "y": 240, "size": 24, "pages": "0-", "color": "CCBBAA", "link": "https://pdf.co/", "fontName": "Comic Sans MS", "fontItalic": true, "fontBold": true, "fontStrikeout": false, "fontUnderline": true}]
40
-
70
+
41
71
  Example images:
42
72
  [{"url": "https://pdfco-test-files.s3.us-west-2.amazonaws.com/pdf-edit/logo.png", "x": 270, "y": 150, "width": 159, "height": 43, "pages": "0"}]
43
-
73
+
44
74
  Example fields:
45
75
  [{"fieldName": "topmostSubform[0].Page1[0].YourSocial_ReadOrderControl[0].f1_05[0]", "pages": "1", "text": "Joan B.", "fontName": "Arial", "size": 6, "fontBold": true, "fontItalic": true, "fontStrikeout": true, "fontUnderline": true}]
46
-
76
+
47
77
  Ref: https://developer.pdf.co/api-reference/pdf-add.md
48
78
  """
49
79
  params = ConversionParams(
@@ -54,10 +84,10 @@ async def pdf_add_annotations_images_fields(
54
84
  name=name,
55
85
  expiration=expiration,
56
86
  )
57
-
87
+
58
88
  # Prepare additional parameters
59
89
  add_params = {}
60
-
90
+
61
91
  if annotations:
62
92
  add_params["annotations"] = annotations
63
93
  if images:
@@ -68,5 +98,5 @@ async def pdf_add_annotations_images_fields(
68
98
  add_params["encrypt"] = encrypt
69
99
  if flatten:
70
100
  add_params["flatten"] = flatten
71
-
72
- return await pdf_add(params, **add_params, api_key=api_key)
101
+
102
+ return await pdf_add(params, **add_params, api_key=api_key)
@@ -7,29 +7,43 @@ from pydantic import Field
7
7
 
8
8
  @mcp.tool()
9
9
  async def ai_invoice_parser(
10
- url: str = Field(description="URL to the source PDF file. Supports publicly accessible links including Google Drive, Dropbox, PDF.co Built-In Files Storage. Use 'upload_file' tool to upload local files."),
11
- api_key: str = Field(description="PDF.co API key. If not provided, will use X_API_KEY environment variable. (Optional)", default=None),
10
+ url: str = Field(
11
+ description="URL to the source PDF file. Supports publicly accessible links including Google Drive, Dropbox, PDF.co Built-In Files Storage. Use 'upload_file' tool to upload local files."
12
+ ),
13
+ api_key: str = Field(
14
+ description="PDF.co API key. If not provided, will use X_API_KEY environment variable. (Optional)",
15
+ default=None,
16
+ ),
12
17
  ) -> BaseResponse:
13
18
  """
14
19
  AI Invoice Parser: Extracts data from invoices using AI.
15
20
  Ref: https://developer.pdf.co/api-reference/ai-invoice-parser.md
16
21
  """
17
-
22
+
18
23
  # Pass arguments directly; ConversionParams now handles str with default=None
19
24
  params = ConversionParams(
20
25
  url=url,
21
26
  )
22
-
27
+
23
28
  return await parse_invoice(params, api_key=api_key)
24
29
 
25
30
 
26
31
  @mcp.tool()
27
32
  async def extract_attachments(
28
33
  url: str = Field(description="URL to the source PDF file."),
29
- httpusername: str = Field(description="HTTP auth user name if required to access source url. (Optional)", default=""),
30
- httppassword: str = Field(description="HTTP auth password if required to access source url. (Optional)", default=""),
34
+ httpusername: str = Field(
35
+ description="HTTP auth user name if required to access source url. (Optional)",
36
+ default="",
37
+ ),
38
+ httppassword: str = Field(
39
+ description="HTTP auth password if required to access source url. (Optional)",
40
+ default="",
41
+ ),
31
42
  password: str = Field(description="Password of PDF file. (Optional)", default=""),
32
- api_key: str = Field(description="PDF.co API key. If not provided, will use X_API_KEY environment variable. (Optional)", default=None),
43
+ api_key: str = Field(
44
+ description="PDF.co API key. If not provided, will use X_API_KEY environment variable. (Optional)",
45
+ default=None,
46
+ ),
33
47
  ) -> BaseResponse:
34
48
  """
35
49
  Extracts attachments from a source PDF file.
@@ -1,14 +1,17 @@
1
- from pathlib import Path
2
1
  from pdfco.mcp.server import mcp
3
2
  from pdfco.mcp.services.client import PDFCoClient
4
3
  from pdfco.mcp.models import BaseResponse
5
4
 
6
5
  from pydantic import Field
7
6
 
7
+
8
8
  @mcp.tool()
9
9
  async def upload_file(
10
10
  file_path: str = Field(description="The absolute path to the file to upload"),
11
- api_key: str = Field(description="PDF.co API key. If not provided, will use X_API_KEY environment variable. (Optional)", default=None)
11
+ api_key: str = Field(
12
+ description="PDF.co API key. If not provided, will use X_API_KEY environment variable. (Optional)",
13
+ default=None,
14
+ ),
12
15
  ) -> BaseResponse:
13
16
  """
14
17
  Upload a file to the PDF.co API
@@ -16,13 +19,14 @@ async def upload_file(
16
19
  try:
17
20
  async with PDFCoClient(api_key=api_key) as client:
18
21
  response = await client.post(
19
- "/v1/file/upload",
22
+ "/v1/file/upload",
20
23
  files={
21
- "file": open(file_path, "rb"),
22
- })
24
+ "file": open(file_path, "rb"),
25
+ },
26
+ )
23
27
  res = response.json()
24
28
  return BaseResponse(
25
- status='success' if res["status"] == 200 else 'error',
29
+ status="success" if res["status"] == 200 else "error",
26
30
  content=res,
27
31
  tips=f"You can use the url {res['url']} to access the file",
28
32
  )
@@ -7,11 +7,22 @@ from pydantic import Field
7
7
 
8
8
  @mcp.tool()
9
9
  async def read_pdf_forms_info(
10
- url: str = Field(description="URL to the source PDF file. Supports publicly accessible links including Google Drive, Dropbox, PDF.co Built-In Files Storage. Use 'upload_file' tool to upload local files."),
11
- httpusername: str = Field(description="HTTP auth user name if required to access source url. (Optional)", default=""),
12
- httppassword: str = Field(description="HTTP auth password if required to access source url. (Optional)", default=""),
10
+ url: str = Field(
11
+ description="URL to the source PDF file. Supports publicly accessible links including Google Drive, Dropbox, PDF.co Built-In Files Storage. Use 'upload_file' tool to upload local files."
12
+ ),
13
+ httpusername: str = Field(
14
+ description="HTTP auth user name if required to access source url. (Optional)",
15
+ default="",
16
+ ),
17
+ httppassword: str = Field(
18
+ description="HTTP auth password if required to access source url. (Optional)",
19
+ default="",
20
+ ),
13
21
  password: str = Field(description="Password of PDF file. (Optional)", default=""),
14
- api_key: str = Field(description="PDF.co API key. If not provided, will use X_API_KEY environment variable. (Optional)", default=None),
22
+ api_key: str = Field(
23
+ description="PDF.co API key. If not provided, will use X_API_KEY environment variable. (Optional)",
24
+ default=None,
25
+ ),
15
26
  ) -> BaseResponse:
16
27
  """
17
28
  Extracts information about fillable PDF fields from an input PDF file.
@@ -23,17 +34,33 @@ async def read_pdf_forms_info(
23
34
  httppassword=httppassword,
24
35
  password=password,
25
36
  )
26
-
37
+
27
38
  return await get_pdf_form_fields_info(params, api_key=api_key)
28
39
 
40
+
29
41
  @mcp.tool(name="fill_forms")
30
42
  async def fill_pdf_forms(
31
- url: str = Field(description="URL to the source PDF file. Supports publicly accessible links including Google Drive, Dropbox, PDF.co Built-In Files Storage. Use 'upload_file' tool to upload local files."),
32
- fields: list = Field(description="List of fields to fill. Each field is a dict with 'fieldName', 'pages', and 'text' properties."),
33
- name: str = Field(description="File name for the generated output. (Optional)", default=""),
34
- httpusername: str = Field(description="HTTP auth user name if required to access source url. (Optional)", default=""),
35
- httppassword: str = Field(description="HTTP auth password if required to access source url. (Optional)", default=""),
36
- api_key: str = Field(description="PDF.co API key. If not provided, will use X_API_KEY environment variable. (Optional)", default=None),
43
+ url: str = Field(
44
+ description="URL to the source PDF file. Supports publicly accessible links including Google Drive, Dropbox, PDF.co Built-In Files Storage. Use 'upload_file' tool to upload local files."
45
+ ),
46
+ fields: list = Field(
47
+ description="List of fields to fill. Each field is a dict with 'fieldName', 'pages', and 'text' properties."
48
+ ),
49
+ name: str = Field(
50
+ description="File name for the generated output. (Optional)", default=""
51
+ ),
52
+ httpusername: str = Field(
53
+ description="HTTP auth user name if required to access source url. (Optional)",
54
+ default="",
55
+ ),
56
+ httppassword: str = Field(
57
+ description="HTTP auth password if required to access source url. (Optional)",
58
+ default="",
59
+ ),
60
+ api_key: str = Field(
61
+ description="PDF.co API key. If not provided, will use X_API_KEY environment variable. (Optional)",
62
+ default=None,
63
+ ),
37
64
  ) -> BaseResponse:
38
65
  """
39
66
  Fill existing form fields in a PDF document.
@@ -48,7 +75,7 @@ async def fill_pdf_forms(
48
75
  ]
49
76
 
50
77
  Use 'read_pdf_forms_info' first to get the fieldName values of the form.
51
-
78
+
52
79
  Ref: https://developer.pdf.co/api-reference/pdf-add#create-fillable-pdf-forms.md
53
80
  """
54
81
  params = ConversionParams(
@@ -57,17 +84,33 @@ async def fill_pdf_forms(
57
84
  httppassword=httppassword,
58
85
  name=name,
59
86
  )
60
-
87
+
61
88
  return await fill_pdf_form_fields(params, fields=fields, api_key=api_key)
62
89
 
90
+
63
91
  @mcp.tool(name="create_fillable_forms")
64
92
  async def create_fillable_forms(
65
- url: str = Field(description="URL to the source PDF file. Supports publicly accessible links including Google Drive, Dropbox, PDF.co Built-In Files Storage. Use 'upload_file' tool to upload local files."),
66
- annotations: list = Field(description="List of form annotations to create. Each annotation can be a textfield or checkbox with properties like 'x', 'y', 'size', 'pages', 'type', and 'id'."),
67
- name: str = Field(description="File name for the generated output. (Optional)", default=""),
68
- httpusername: str = Field(description="HTTP auth user name if required to access source url. (Optional)", default=""),
69
- httppassword: str = Field(description="HTTP auth password if required to access source url. (Optional)", default=""),
70
- api_key: str = Field(description="PDF.co API key. If not provided, will use X_API_KEY environment variable. (Optional)", default=None),
93
+ url: str = Field(
94
+ description="URL to the source PDF file. Supports publicly accessible links including Google Drive, Dropbox, PDF.co Built-In Files Storage. Use 'upload_file' tool to upload local files."
95
+ ),
96
+ annotations: list = Field(
97
+ description="List of form annotations to create. Each annotation can be a textfield or checkbox with properties like 'x', 'y', 'size', 'pages', 'type', and 'id'."
98
+ ),
99
+ name: str = Field(
100
+ description="File name for the generated output. (Optional)", default=""
101
+ ),
102
+ httpusername: str = Field(
103
+ description="HTTP auth user name if required to access source url. (Optional)",
104
+ default="",
105
+ ),
106
+ httppassword: str = Field(
107
+ description="HTTP auth password if required to access source url. (Optional)",
108
+ default="",
109
+ ),
110
+ api_key: str = Field(
111
+ description="PDF.co API key. If not provided, will use X_API_KEY environment variable. (Optional)",
112
+ default=None,
113
+ ),
71
114
  ) -> BaseResponse:
72
115
  """
73
116
  Create new fillable form elements in a PDF document.
@@ -101,5 +144,5 @@ async def create_fillable_forms(
101
144
  httppassword=httppassword,
102
145
  name=name,
103
146
  )
104
-
105
- return await fill_pdf_form_fields(params, annotations=annotations, api_key=api_key)
147
+
148
+ return await fill_pdf_form_fields(params, annotations=annotations, api_key=api_key)
@@ -6,10 +6,14 @@ from pdfco.mcp.models import BaseResponse
6
6
 
7
7
  from pydantic import Field
8
8
 
9
+
9
10
  @mcp.tool()
10
11
  async def get_job_check(
11
12
  job_id: str = Field(description="The ID of the job to get the status of"),
12
- api_key: str = Field(description="PDF.co API key. If not provided, will use X_API_KEY environment variable. (Optional)", default=None)
13
+ api_key: str = Field(
14
+ description="PDF.co API key. If not provided, will use X_API_KEY environment variable. (Optional)",
15
+ default=None,
16
+ ),
13
17
  ) -> BaseResponse:
14
18
  """
15
19
  Check the status and results of a job
@@ -22,9 +26,12 @@ async def get_job_check(
22
26
  """
23
27
  try:
24
28
  async with PDFCoClient(api_key=api_key) as client:
25
- response = await client.post("/v1/job/check", json={
26
- "jobId": job_id,
27
- })
29
+ response = await client.post(
30
+ "/v1/job/check",
31
+ json={
32
+ "jobId": job_id,
33
+ },
34
+ )
28
35
  json_data = response.json()
29
36
  return BaseResponse(
30
37
  status=json_data["status"],
@@ -39,12 +46,20 @@ async def get_job_check(
39
46
  content=str(e),
40
47
  )
41
48
 
49
+
42
50
  @mcp.tool()
43
51
  async def wait_job_completion(
44
52
  job_id: str = Field(description="The ID of the job to get the status of"),
45
- interval: int = Field(description="The interval to check the status of the job (seconds)", default=1),
46
- timeout: int = Field(description="The timeout to wait for the job to complete (seconds)", default=300),
47
- api_key: str = Field(description="PDF.co API key. If not provided, will use X_API_KEY environment variable. (Optional)", default=None)
53
+ interval: int = Field(
54
+ description="The interval to check the status of the job (seconds)", default=1
55
+ ),
56
+ timeout: int = Field(
57
+ description="The timeout to wait for the job to complete (seconds)", default=300
58
+ ),
59
+ api_key: str = Field(
60
+ description="PDF.co API key. If not provided, will use X_API_KEY environment variable. (Optional)",
61
+ default=None,
62
+ ),
48
63
  ) -> BaseResponse:
49
64
  """
50
65
  Wait for a job to complete
@@ -7,27 +7,64 @@ from pydantic import Field
7
7
 
8
8
  @mcp.tool()
9
9
  async def pdf_merge(
10
- url: str = Field(description="URLs to the source files as a comma-separated list. Supports PDF, DOC, DOCX, RTF, TXT, XLS, XLSX, CSV, images, and more. Supports publicly accessible links including Google Drive, Dropbox, PDF.co Built-In Files Storage. Use 'upload_file' tool to upload local files."),
11
- httpusername: str = Field(description="HTTP auth user name if required to access source url. (Optional)", default=""),
12
- httppassword: str = Field(description="HTTP auth password if required to access source url. (Optional)", default=""),
13
- name: str = Field(description="File name for the generated output. (Optional)", default=""),
14
- api_key: str = Field(description="PDF.co API key. If not provided, will use X_API_KEY environment variable. (Optional)", default=None),
10
+ url: str = Field(
11
+ description="URLs to the source files as a comma-separated list. Supports PDF, DOC, DOCX, RTF, TXT, XLS, XLSX, CSV, images, and more. Supports publicly accessible links including Google Drive, Dropbox, PDF.co Built-In Files Storage. Use 'upload_file' tool to upload local files."
12
+ ),
13
+ httpusername: str = Field(
14
+ description="HTTP auth user name if required to access source url. (Optional)",
15
+ default="",
16
+ ),
17
+ httppassword: str = Field(
18
+ description="HTTP auth password if required to access source url. (Optional)",
19
+ default="",
20
+ ),
21
+ name: str = Field(
22
+ description="File name for the generated output. (Optional)", default=""
23
+ ),
24
+ api_key: str = Field(
25
+ description="PDF.co API key. If not provided, will use X_API_KEY environment variable. (Optional)",
26
+ default=None,
27
+ ),
15
28
  ) -> BaseResponse:
16
29
  """
17
30
  Merge PDF from two or more PDF, DOC, XLS, images, even ZIP with documents and images into a new PDF.
18
31
  Ref: https://developer.pdf.co/api-reference/merge/various-files.md
19
32
  """
20
- return await merge_pdf(ConversionParams(url=url, httpusername=httpusername, httppassword=httppassword, name=name), api_key=api_key)
33
+ return await merge_pdf(
34
+ ConversionParams(
35
+ url=url, httpusername=httpusername, httppassword=httppassword, name=name
36
+ ),
37
+ api_key=api_key,
38
+ )
39
+
21
40
 
22
41
  @mcp.tool()
23
42
  async def pdf_split(
24
- url: str = Field(description="URL to the source PDF file. Supports publicly accessible links including Google Drive, Dropbox, PDF.co Built-In Files Storage. Use 'upload_file' tool to upload local files."),
25
- pages: str = Field(description="Comma-separated indices of pages (or page ranges) that you want to use. The first-page index is 1. For example: '1,3,5-7' or '1-2,4-'. Use '*' to split every page into separate files."),
26
- httpusername: str = Field(description="HTTP auth user name if required to access source url. (Optional)", default=""),
27
- httppassword: str = Field(description="HTTP auth password if required to access source url. (Optional)", default=""),
28
- password: str = Field(description="Password of the PDF file. (Optional)", default=""),
29
- name: str = Field(description="Base file name for the generated output files. (Optional)", default=""),
30
- api_key: str = Field(description="PDF.co API key. If not provided, will use X_API_KEY environment variable. (Optional)", default=None),
43
+ url: str = Field(
44
+ description="URL to the source PDF file. Supports publicly accessible links including Google Drive, Dropbox, PDF.co Built-In Files Storage. Use 'upload_file' tool to upload local files."
45
+ ),
46
+ pages: str = Field(
47
+ description="Comma-separated indices of pages (or page ranges) that you want to use. The first-page index is 1. For example: '1,3,5-7' or '1-2,4-'. Use '*' to split every page into separate files."
48
+ ),
49
+ httpusername: str = Field(
50
+ description="HTTP auth user name if required to access source url. (Optional)",
51
+ default="",
52
+ ),
53
+ httppassword: str = Field(
54
+ description="HTTP auth password if required to access source url. (Optional)",
55
+ default="",
56
+ ),
57
+ password: str = Field(
58
+ description="Password of the PDF file. (Optional)", default=""
59
+ ),
60
+ name: str = Field(
61
+ description="Base file name for the generated output files. (Optional)",
62
+ default="",
63
+ ),
64
+ api_key: str = Field(
65
+ description="PDF.co API key. If not provided, will use X_API_KEY environment variable. (Optional)",
66
+ default=None,
67
+ ),
31
68
  ) -> BaseResponse:
32
69
  """
33
70
  Split a PDF into multiple PDF files using page indexes or page ranges.
@@ -41,5 +78,5 @@ async def pdf_split(
41
78
  password=password,
42
79
  name=name,
43
80
  )
44
-
81
+
45
82
  return await split_pdf(params, api_key=api_key)
@@ -7,15 +7,39 @@ from pydantic import Field
7
7
 
8
8
  @mcp.tool(name="find_text")
9
9
  async def find_text(
10
- url: str = Field(description="URL to the source PDF file. Supports publicly accessible links including Google Drive, Dropbox, PDF.co Built-In Files Storage. Use 'upload_file' tool to upload local files."),
11
- searchString: str = Field(description="Text to search. Can support regular expressions if regexSearch is set to True."),
12
- httpusername: str = Field(description="HTTP auth user name if required to access source url. (Optional)", default=""),
13
- httppassword: str = Field(description="HTTP auth password if required to access source url. (Optional)", default=""),
14
- pages: str = Field(description="Comma-separated list of page indices (or ranges) to process. Leave empty for all pages. Example: '0,2-5,7-'. The first-page index is 0. (Optional)", default=""),
15
- wordMatchingMode: str = Field(description="Values can be either SmartMatch, ExactMatch, or None. (Optional)", default=None),
16
- password: str = Field(description="Password of the PDF file. (Optional)", default=""),
17
- regexSearch: bool = Field(description="Set to True to enable regular expressions in the search string. (Optional)", default=False),
18
- api_key: str = Field(description="PDF.co API key. If not provided, will use X_API_KEY environment variable. (Optional)", default=None),
10
+ url: str = Field(
11
+ description="URL to the source PDF file. Supports publicly accessible links including Google Drive, Dropbox, PDF.co Built-In Files Storage. Use 'upload_file' tool to upload local files."
12
+ ),
13
+ searchString: str = Field(
14
+ description="Text to search. Can support regular expressions if regexSearch is set to True."
15
+ ),
16
+ httpusername: str = Field(
17
+ description="HTTP auth user name if required to access source url. (Optional)",
18
+ default="",
19
+ ),
20
+ httppassword: str = Field(
21
+ description="HTTP auth password if required to access source url. (Optional)",
22
+ default="",
23
+ ),
24
+ pages: str = Field(
25
+ description="Comma-separated list of page indices (or ranges) to process. Leave empty for all pages. Example: '0,2-5,7-'. The first-page index is 0. (Optional)",
26
+ default="",
27
+ ),
28
+ wordMatchingMode: str = Field(
29
+ description="Values can be either SmartMatch, ExactMatch, or None. (Optional)",
30
+ default=None,
31
+ ),
32
+ password: str = Field(
33
+ description="Password of the PDF file. (Optional)", default=""
34
+ ),
35
+ regexSearch: bool = Field(
36
+ description="Set to True to enable regular expressions in the search string. (Optional)",
37
+ default=False,
38
+ ),
39
+ api_key: str = Field(
40
+ description="PDF.co API key. If not provided, will use X_API_KEY environment variable. (Optional)",
41
+ default=None,
42
+ ),
19
43
  ) -> BaseResponse:
20
44
  """
21
45
  Find text in PDF and get coordinates. Supports regular expressions.
@@ -28,18 +52,36 @@ async def find_text(
28
52
  pages=pages,
29
53
  password=password,
30
54
  )
31
-
32
- return await find_text_in_pdf(params, searchString, regexSearch, wordMatchingMode, api_key=api_key)
55
+
56
+ return await find_text_in_pdf(
57
+ params, searchString, regexSearch, wordMatchingMode, api_key=api_key
58
+ )
33
59
 
34
60
 
35
61
  @mcp.tool(name="find_table")
36
62
  async def find_table(
37
- url: str = Field(description="URL to the source PDF file. Supports publicly accessible links including Google Drive, Dropbox, PDF.co Built-In Files Storage. Use 'upload_file' tool to upload local files."),
38
- httpusername: str = Field(description="HTTP auth user name if required to access source url. (Optional)", default=""),
39
- httppassword: str = Field(description="HTTP auth password if required to access source url. (Optional)", default=""),
40
- pages: str = Field(description="Comma-separated list of page indices (or ranges) to process. Leave empty for all pages. Example: '0,2-5,7-'. The first-page index is 0. (Optional)", default=""),
41
- password: str = Field(description="Password of the PDF file. (Optional)", default=""),
42
- api_key: str = Field(description="PDF.co API key. If not provided, will use X_API_KEY environment variable. (Optional)", default=None),
63
+ url: str = Field(
64
+ description="URL to the source PDF file. Supports publicly accessible links including Google Drive, Dropbox, PDF.co Built-In Files Storage. Use 'upload_file' tool to upload local files."
65
+ ),
66
+ httpusername: str = Field(
67
+ description="HTTP auth user name if required to access source url. (Optional)",
68
+ default="",
69
+ ),
70
+ httppassword: str = Field(
71
+ description="HTTP auth password if required to access source url. (Optional)",
72
+ default="",
73
+ ),
74
+ pages: str = Field(
75
+ description="Comma-separated list of page indices (or ranges) to process. Leave empty for all pages. Example: '0,2-5,7-'. The first-page index is 0. (Optional)",
76
+ default="",
77
+ ),
78
+ password: str = Field(
79
+ description="Password of the PDF file. (Optional)", default=""
80
+ ),
81
+ api_key: str = Field(
82
+ description="PDF.co API key. If not provided, will use X_API_KEY environment variable. (Optional)",
83
+ default=None,
84
+ ),
43
85
  ) -> BaseResponse:
44
86
  """
45
87
  Find tables in PDF and get their coordinates.
@@ -52,5 +94,5 @@ async def find_table(
52
94
  pages=pages,
53
95
  password=password,
54
96
  )
55
-
56
- return await find_table_in_pdf(params, api_key=api_key)
97
+
98
+ return await find_table_in_pdf(params, api_key=api_key)