search_posts
Find and retrieve public Medium stories based on a search query. Specify limit to control results count.
Instructions
Read-only. Medium-side search across public stories.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | ||
| limit | No |
Implementation Reference
- src/medium_ops/client.py:459-481 (handler)MediumClient.search_posts – executes the GraphQL query against Medium's _/graphql endpoint. Accepts 'query' (required) and 'limit' (default 10). Returns post items with id, title, mediumUrl, firstPublishedAt, clapCount, and creator info.
def search_posts(self, *, query: str, limit: int = 10) -> list[dict[str, Any]]: data = self._gql( operation="SearchPosts", query=""" query SearchPosts($query: String!, $paging: PagingOptions) { search(query: $query) { posts(paging: $paging) { items { id title mediumUrl firstPublishedAt clapCount creator { id username name } } } } } """, variables={"query": query, "paging": {"limit": limit}}, ) items = (((data.get("search") or {}).get("posts") or {}).get("items")) or [] return items[:limit] - src/medium_ops/mcp/server.py:125-137 (schema)Tool schema/registration in the TOOLS dict. Defines search_posts as a read-only tool requiring 'query' (string), with optional 'limit' (integer, default 10).
"search_posts": { "description": ( "Read-only. Medium-side search across public stories." ), "input_schema": { "type": "object", "properties": { "query": {"type": "string"}, "limit": {"type": "integer", "default": 10}, }, "required": ["query"], }, }, - src/medium_ops/mcp/server.py:459-460 (registration)Dispatch handler in _dispatch() that routes the 'search_posts' tool call to MediumClient.search_posts, passing query (required) and limit (default 10).
if name == "search_posts": return c.search_posts(query=args["query"], limit=args.get("limit", 10)) - src/medium_ops/cli.py:355-361 (helper)CLI helper wrapper that calls the same client.search_posts method from the command line interface.
def posts_search( query: str, limit: int = typer.Option(10, "--limit"), ) -> None: """Medium-side full-text search.""" with _client() as c: _json(c.search_posts(query=query, limit=limit))