-
-
Notifications
You must be signed in to change notification settings - Fork 269
Add ask-agent CLI and MCP integration tool #162
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
base: main
Are you sure you want to change the base?
Conversation
- Add main_async_single_query() function to handle single query execution - Add --question/-q parameter to start command - Route to non-interactive mode when --question is provided - Output response directly to stdout for easy scripting - Maintain backward compatibility with interactive mode
- Update client to call the new **ask_agent** tool instead of ask_code_graph. - Change CLI flag from `--question` to `--ask-agent` for clearer intent. - Add `StdioServerParameters` and redirect server stderr to `/dev/null` to suppress noisy logs while keeping MCP communication intact. - Replace the tool registration entry with **ask_agent**, expanding its description and input schema to guide users on asking code‑base questions. - Adjust logging statements to reference the new tool name.
Summary of ChangesHello @qdrddr, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the utility of the codebase RAG system by introducing a non-interactive query mode. This allows users to programmatically ask questions about the codebase via a new CLI flag or through an MCP tool, making the system more versatile for automation and integration with other tools. The changes also include improvements to logging for non-interactive use cases and an expansion of the underlying toolset available to the RAG agent. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces a non-interactive query mode via a new CLI flag and integrates it as an ask_agent tool within the MCP server. The changes are well-structured, with a new main_async_single_query function for single queries and a dedicated mcp/client.py for testing the MCP tool. The logging is also improved for the non-interactive mode to provide clean output. My main feedback is to ensure consistency in the naming of the new CLI flag across the application, as I've detailed in my comments on codebase_rag/main.py.
- Fix JSONRPC parsing errors by disabling ANSI colors in logging - Redirect Rich console output to stderr to avoid stdout corruption - Increase RAG orchestrator retries to handle output validation Cherry-picked from dev branch (21a1b5a)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work on the ask-agent feature!
A few things to address:
- Silent error handling makes debugging impossible:
except Exception:
# Fail silently without logging or printing error details
return {"output": "There was an error processing your question", "error": True}This is in both ask_agent (tools.py) and call_tool (server.py). Even with MCP_ENABLE_LOGGING=1, errors aren't logged anywhere.
Please log errors and include some info in the response:
except Exception as e:
logger.error(f"ask_agent error: {e}")
return {
"output": "There was an error processing your question",
"error": True,
"error_type": type(e).__name__,
}-
mcp/client.pyis described as a "test" client but lives in the main package. Should it be intests/instead? -
The PR adds new MCP tools (
shell_command,document_analyzer,semantic_search,get_function_source) but doesn't mention them in the description. Please document these additions.
|
This is actually a good point that I didn't think about. Happy to silence them for now until we find a better way. Please add documentation on metnioned on point 3, and I will approve this PR. Thanks again @qdrddr |
|
|
vitali87
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your patience and for adding the documentation as requested!
I've recently done a major refactoring to centralize strings and enforce stricter coding standards. This PR predates those changes, so there are quite a few adjustments needed to align with the new patterns (see CONTRIBUTING.md).
Given the scope of changes required, I'd like to offer you two options:
Option 1: You address the remaining items:
- Remove all docstrings (see "No Comments or Docstrings" in
CONTRIBUTING.md) - Replace
dict[str, Any]with TypedDict - Move tool/parameter descriptions to
tool_descriptions.py - Install pre-commit hooks:
pre-commit install
Option 2: I can make these adjustments myself and merge, with attribution to you.
Let me know which you'd prefer!
--ask-agentCLI flag for non-interactive queriesask_agenttool within MCPask_agent - utilizes the RAG pipeline similar to the interactive mode and provides it as a tool. Often gives a better responce when used from the MCP Client.
Sometimes you want to be able to access the code-graph from CLI non-interactively by asking a single question.