Mirror every read-only pwc command as an MCP tool - #13
Merged
Merged
Conversation
Each read-only CLI research command becomes one MCP tool and every research flag of that command becomes a typed tool parameter, so MCP results match `pwc ... --json` instead of a second implementation of the query logic. - Add pwc_cli.queries: run the CLI handlers in-process through the CLI's own parser with a result sink (no subprocess or stdout capture). A strict parser raises UsageError instead of exiting; only read-only commands are reachable. - CLI: route every --json emission through _emit_json, accept parser_class in build_parser, treat impossible flag combinations as usage errors, and percent-encode paper references in request paths like the MCP catalog. - MCP server: 20 tools (10 new: recent/trending papers, tasks, methods, conferences, organizations, frameworks). Every result carries the complete CLI JSON as `data` beside typed projections. get_benchmark gains max_parameters, require_metrics, minimum/maximum_metrics, sort_metric and pareto; get_paper_info gains include_resources, include_evaluations and Hugging Face artifacts; list_tasks/list_benchmarks gain grouping by area. - Catalog client serves the CLI handlers from the shared per-path cache and resolves paper URLs, legacy IDs and exact titles before the CLI runs. - search_papers accepts hybrid mode (counted toward the semantic rate limit); list_papers orders by trending like the CLI and drops the unsupported order_by=title. - tests/test_parity.py fails when the CLI parser and tool schemas drift. - Skill, README and SPEC updated; pwc-cli 0.4.1, pwc-mcp 0.2.0. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…evidence Unknown or ambiguous task, method, benchmark, conference, organization, framework, area, and paper-title lookups now return the CLI's own message (including its closest-match hint) so an agent can correct the call. Transport, HTTP, and response-shape failures keep the generic message, and nothing is logged. Tool descriptions now tell agents to start best/SOTA-model questions with get_task, list_benchmarks, and get_benchmark rather than search. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
All chat traffic reaches the MCP server from one gateway address, so the per-client limits were shared by every concurrent chat user. A direct loopback client that carries no X-Forwarded-For may now send X-PwC-MCP-Client to name the identity that the request, semantic, and concurrency limits apply to. nginx always adds X-Forwarded-For to proxied traffic, so public clients cannot use the header. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Collaborator
Author
|
Added in |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Every read-only
pwcCLI research command is now one MCP tool, and every research flag of that command is a typed tool parameter. The tools run the CLI handlers in-process through the CLI's own parser, so validation, fail-closed filter checks, and the JSON payload are the CLI's rather than a second implementation. Every result carries the completepwc ... --jsondocument asdatabeside the typed projections existing clients already read.This closes the gaps found in the staging comparison against the reference chat: leaderboard filtering by parameter count and metric, per-paper evaluation tables, and model/artifact resources are now reachable over MCP.
Tools
search_paperspwc searchhybridmodeget_paper_infopwc paper infoinclude_resources,include_evaluations, HF artifactsread_paperpwc paper readlist_paperspwc paper listall_versions,include_resources,has_official_implementation,trendingorderlist_recent_paperspwc paper recentlist_trending_paperspwc paper trendingget_related_paperspwc paper relatedget_paper_lineagepwc paper lineage listget_taskpwc task --namelist_taskspwc task listget_methodpwc method --namelist_methodspwc method listget_conference/list_conferencesget_organization/list_organizationsget_framework/list_frameworksget_benchmarkpwc benchmark --namemax_parameters,require_metrics,minimum_metrics,maximum_metrics,sort_metric,pareto,matched_countlist_benchmarkspwc benchmark listgroup_by_area,area,benchmarks_per_task,order_by,order_directionmcp_server/tests/test_parity.pyenumerates the CLI parser and fails when any research flag lacks a parameter, any parameter lacks a flag, or choice sets drift.Parity rules and deliberate divergences
published_after/published_before,limit(for--page-size),authors,order_direction,minimum_evaluations,include_evaluations.--json,--implementation-coverage,--flat) have no parameter; MCP output is always structured.limitstays capped at 25 rows (hosting contract); CLI defaults above 25 are clipped.search_paperskeepskeywordas default.hybridis available and, because it runs dense retrieval upstream, counts toward the 10/minute semantic budget alongsidesemantic.get_paper_infokeepsinclude_resourcesdefaulting to true sorepositories/project_pagesremain populated for existing clients.Behavior changes for existing clients
list_papersdefaultorder_byis nowtrending(CLI default) instead ofdate_published;titlewas removed because the/papers/API does not accept it.list_benchmarkswithtasknow returns trend-ranked rows like the CLI unlessorder_byis set.get_tasknow returns the CLI task page (ranked benchmarks, common methods, trending papers) indata; typed fields are unchanged.limitvalues follow the CLI:list_papers20,get_benchmark20,get_related_papers4 (max 20).pwc task list --group-by-area --page 2andpwc benchmark list --order-by trendingwithout--tasknow exit 2 (usage) instead of 4; paper references are percent-encoded in request paths.Verification
uv run --project mcp_server pytest mcp_server/tests: 42 passed.uv run --project standalone_cli --with pytest pytest standalone_cli/tests: 82 passed.standalone_cli/scripts/check_contract.pypasses;uv lockrefreshed for pwc-cli 0.4.1 / pwc-mcp 0.2.0.get_benchmarkon MMLU withmax_parameters: "4B"(20 matching rows) andsort_metric: "Accuracy"withminimum_metrics(176 of 240 rows matched),get_paper_infoon Gemma 3 withinclude_evaluations(22 rows), groupedlist_tasks/list_benchmarks, and a CLI usage error surfaced verbatim (unknown metric(s): latency; available metrics: Accuracy).Follow-ups (not in this PR)
huggingface/paperswithcodeshould adopt the new parameters and tool names in its MCP tool registration and research prompt.Task not found: language-modelling; closest results: Language Modeling) are still masked by the server's generic catalog error policy; consider passing them through.🤖 Generated with Claude Code