Skip to content

Commit 412387d

Browse files
committed
change all the non-string type to string, and use pattern to valid them.
1 parent d3b74d4 commit 412387d

File tree

1 file changed

+40
-34
lines changed

1 file changed

+40
-34
lines changed

src/serper_mcp_server/schemas.py

Lines changed: 40 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,29 @@ class BaseRequest(BaseModel):
1515
hl: Optional[str] = Field(
1616
None, description="The language to search in, e.g. en, es, fr, de, etc."
1717
)
18-
page: Optional[int] = Field(
19-
1,
20-
ge=1,
21-
description="The page number to return, first page is 1 (integer value)",
18+
page: Optional[str] = Field(
19+
"1",
20+
pattern=r"^[1-9]\d*$",
21+
description="The page number to return, first page is 1 (integer value as string)",
2222
)
2323

2424

2525
class SearchRequest(BaseRequest):
2626
tbs: Optional[str] = Field(
2727
None, description="The time period to search in, e.g. d, w, m, y"
2828
)
29-
num: int = Field(
30-
10,
31-
le=100,
32-
description="The number of results to return, max is 100 (integer value)",
29+
num: str = Field(
30+
"10",
31+
pattern=r"^([1-9]|[1-9]\d|100)$",
32+
description="The number of results to return, max is 100 (integer value as string)",
3333
)
3434

3535

3636
class AutocorrectRequest(BaseRequest):
37-
autocorrect: Optional[bool] = Field(
38-
True, description="Automatically correct (boolean value: true/false)"
37+
autocorrect: Optional[str] = Field(
38+
"true",
39+
pattern=r"^(true|false)$",
40+
description="Automatically correct (boolean value as string: 'true' or 'false')",
3941
)
4042

4143

@@ -50,20 +52,21 @@ class MapsRequest(BaseModel):
5052
hl: Optional[str] = Field(
5153
None, description="The language to search in, e.g. en, es, fr, de, etc."
5254
)
53-
page: Optional[int] = Field(
54-
1,
55-
ge=1,
56-
description="The page number to return, first page is 1 (integer value)",
55+
page: Optional[str] = Field(
56+
"1",
57+
pattern=r"^[1-9]\d*$",
58+
description="The page number to return, first page is 1 (integer value as string)",
5759
)
5860

5961

6062
class ReviewsRequest(BaseModel):
6163
fid: str = Field(..., description="The FID")
6264
cid: Optional[str] = Field(None, description="The CID to search in")
6365
placeId: Optional[str] = Field(None, description="The place ID to search in")
64-
sortBy: Optional[ReviewSortBy] = Field(
65-
ReviewSortBy.mostRelevant,
66-
description="The sort order to use (enum value: 'mostRelevant', 'newest', 'highestRating', 'lowestRating')",
66+
sortBy: Optional[str] = Field(
67+
"mostRelevant",
68+
pattern=r"^(mostRelevant|newest|highestRating|lowestRating)$",
69+
description="The sort order to use (enum value as string: 'mostRelevant', 'newest', 'highestRating', 'lowestRating')",
6770
)
6871
topicId: Optional[str] = Field(None, description="The topic ID to search in")
6972
nextPageToken: Optional[str] = Field(None, description="The next page token to use")
@@ -76,13 +79,15 @@ class ReviewsRequest(BaseModel):
7679

7780

7881
class ShoppingRequest(BaseRequest):
79-
autocorrect: Optional[bool] = Field(
80-
True, description="Automatically correct (boolean value: true/false)"
82+
autocorrect: Optional[str] = Field(
83+
"true",
84+
pattern=r"^(true|false)$",
85+
description="Automatically correct (boolean value as string: 'true' or 'false')",
8186
)
82-
num: int = Field(
83-
10,
84-
le=100,
85-
description="The number of results to return, max is 100 (integer value)",
87+
num: str = Field(
88+
"10",
89+
pattern=r"^([1-9]|[1-9]\d|100)$",
90+
description="The number of results to return, max is 100 (integer value as string)",
8691
)
8792

8893

@@ -98,21 +103,22 @@ class LensRequest(BaseModel):
98103

99104
class ParentsRequest(BaseModel):
100105
q: str = Field(..., description="The query to search for")
101-
num: int = Field(
102-
10,
103-
le=100,
104-
description="The number of results to return, max is 100 (integer value)",
106+
num: str = Field(
107+
"10",
108+
pattern=r"^([1-9]|[1-9]\d|100)$",
109+
description="The number of results to return, max is 100 (integer value as string)",
105110
)
106-
page: Optional[int] = Field(
107-
1,
108-
ge=1,
109-
description="The page number to return, first page is 1 (integer value)",
111+
page: Optional[str] = Field(
112+
"1",
113+
pattern=r"^[1-9]\d*$",
114+
description="The page number to return, first page is 1 (integer value as string)",
110115
)
111116

112117

113118
class WebpageRequest(BaseModel):
114119
url: str = Field(..., description="The url to scrape")
115-
includeMarkdown: Optional[bool] = Field(
116-
False,
117-
description="Include markdown in the response (boolean value: true/false)",
120+
includeMarkdown: Optional[str] = Field(
121+
"false",
122+
pattern=r"^(true|false)$",
123+
description="Include markdown in the response (boolean value as string: 'true' or 'false')",
118124
)

0 commit comments

Comments
 (0)