Skip to content

feat(mcp2.0): add and replace tools with mcp #261

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open

Conversation

Kunlun-Zhu
Copy link
Member

@Kunlun-Zhu Kunlun-Zhu commented Jul 4, 2025

Closes #

πŸ“‘ Description

βœ… Checks

  • My pull request adheres to the code style of this project
  • My code requires changes to the documentation
  • I have updated the documentation as required
  • All the tests have passed
  • Branch name follows type/descript (e.g. feature/add-llm-agents)
  • Ready for code review

β„Ή Additional Information

@Kunlun-Zhu Kunlun-Zhu requested a review from lwaekfjlk July 4, 2025 17:30
@Kunlun-Zhu Kunlun-Zhu requested a review from Copilot July 4, 2025 18:02
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces MCP (Meta Compute Platform) integration across the TinyScientist modules, replacing or augmenting existing local tools with a centralized MCP client/server model. Key changes include:

  • Added tiny_scientist/utils/mcp_client.py for a generic MCP client and corresponding server implementations under tiny_scientist/mcp/.
  • Updated imports in core classes (Writer, Thinker, Reviewer, Coder, Scientist) to accept an mcp_client and fall back to legacy tools when MCP is unavailable.
  • Added a convenience script to launch all MCP servers and updated dependencies/config templates to support the new MCP setup.

Reviewed Changes

Copilot reviewed 13 out of 15 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tiny_scientist/writer.py Switched to mcp.tool imports, added mcp_client fallback logic for search & diagram tools
tiny_scientist/utils/mcp_client.py New MCPClient implementation with start/stop/call methods
tiny_scientist/mcp/tool.py Tool definitions updated for MCP namespace (missing os import)
tiny_scientist/mcp/*.py Added MCP server modules for paper search, drawer, and code search
scripts/run_mcp_servers.py New script to start and interactively manage MCP servers
pyproject.toml & config.template.toml Added mcp, fastmcp, httpx deps and MCP server templates
Comments suppressed due to low confidence (3)

tiny_scientist/utils/mcp_client.py:21

  • Type annotation subprocess.Popen[str] is invalidβ€”Popen is not a generic class; use subprocess.Popen[Any] or omit the type parameter.
        self.servers: Dict[str, subprocess.Popen[str]] = {}

tiny_scientist/utils/mcp_client.py:1

  • The new MCPClient and MCP server code are significant features but have no accompanying tests; consider adding unit tests for methods like start_server, call_tool, and health_check.
import json

tiny_scientist/mcp/tool.py:11

  • The module uses os.path but does not import os; add import os at the top to avoid NameError.
import toml

# Create tool call request
request = {
"jsonrpc": "2.0",
"id": 1,
Copy link
Preview

Copilot AI Jul 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using a static JSON-RPC id for every call can cause conflicts if multiple calls happen concurrently; consider generating unique or incrementing IDs per request.

Copilot uses AI. Check for mistakes.

self.drawer: BaseTool = DrawerTool(model, prompt_template_dir, temperature)
self.mcp_client = mcp_client
# Fallback to traditional tools if MCP is not available
self.searcher: Optional[BaseTool] = PaperSearchTool(s2_api_key=s2_api_key) if not mcp_client else None
Copy link
Preview

Copilot AI Jul 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fallback initialization of legacy tools when mcp_client is missing is duplicated in multiple classes; consider extracting into a shared factory/helper to reduce duplication.

Copilot uses AI. Check for mistakes.

pyproject.toml Outdated
Comment on lines +35 to +37
fastmcp = "*"
mcp = "*"
httpx = "*"
Copy link
Preview

Copilot AI Jul 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Using wildcard versions (*) for critical dependencies can lead to unpredictable breakage; pin fastmcp, mcp, and httpx to specific version ranges for reproducible builds.

Suggested change
fastmcp = "*"
mcp = "*"
httpx = "*"
fastmcp = "^1.0.0"
mcp = "^2.0.0"
httpx = "^0.24.0"

Copilot uses AI. Check for mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant