Conversation
74c90c5 to
8e11698
Compare
There was a problem hiding this comment.
Greptile Summary
This PR enhances logging and debugging capabilities for the MCP (Model Context Protocol) server by implementing comprehensive tracing infrastructure that writes to stderr. The changes introduce structured logging throughout the MCP codebase while maintaining clean stdout output for programmatic consumption.
The core modification redirects all CLI tracing output from stdout to stderr in the cargo-shuttle library's tracing setup. This ensures that debugging information doesn't interfere with structured outputs like JSON responses that tools may rely on. The MCP server itself gains extensive instrumentation with #[instrument(skip(self))] attributes added to all tool methods (deploy, deployment_list, deployment_status, logs, project_status, project_list, search_docs), enabling automatic logging of function entry/exit and parameters.
To support this tracing infrastructure, Debug trait derivations are added to all MCP tool argument structs (DeployArgs, DeploymentListArgs, DeploymentStatusArgs, ProjectStatusArgs, LogsArgs, SearchDocsArgs). This allows the tracing framework to serialize and log these structures for debugging purposes. The tracing dependency is also added to the MCP crate's Cargo.toml to enable these features.
Additionally, the PR simplifies the project listing functionality by removing the ProjectListArgs struct and making the project_list function always operate in the current directory, eliminating unnecessary parameterization since project listing is a global operation that queries the user's Shuttle account rather than being filesystem-dependent.
Simple startup logging is added to the MCP server initialization with eprintln! statements to provide immediate feedback about server lifecycle events.
Important Files Changed
Changed Files
| Filename | Score | Overview |
|---|---|---|
| cargo-shuttle/src/lib.rs | 5/5 | Redirects CLI tracing output from stdout to stderr for clean separation of logs and structured output |
| mcp/Cargo.toml | 5/5 | Adds tracing dependency to enable instrumentation and structured logging in MCP server |
| mcp/src/lib.rs | 5/5 | Adds basic startup logging with eprintln statements for MCP server lifecycle visibility |
| mcp/src/mcp.rs | 4/5 | Adds comprehensive tracing instrumentation to all tool methods and simplifies project_list function |
| mcp/src/utils.rs | 5/5 | Adds debug logging to run_tool function with tracing instrumentation integration |
| mcp/src/tools/deployment.rs | 5/5 | Adds Debug trait to deployment argument structs for tracing support |
| mcp/src/tools/project.rs | 5/5 | Simplifies project_list by removing parameters and adds Debug trait to ProjectStatusArgs |
| mcp/src/tools/logs.rs | 5/5 | Adds Debug trait to LogsArgs struct for consistency with other tool argument structures |
Confidence score: 4/5
- This PR is safe to merge with low risk of causing production issues
- Score reflects well-structured logging improvements with minimal complexity changes
- Pay attention to mcp/src/mcp.rs for the function signature changes in project_list
Sequence Diagram
sequenceDiagram
participant User
participant CLI as "Shuttle CLI"
participant MCP as "MCP Server"
participant Tools as "MCP Tools"
participant Stderr as "stderr output"
User->>CLI: "shuttle mcp start"
CLI->>CLI: "setup_tracing(debug)"
Note over CLI,Stderr: Tracing now writes to stderr
CLI->>Stderr: "Starting Shuttle MCP server..."
CLI->>MCP: "run_mcp_server()"
MCP->>MCP: "ShuttleMcpServer::new()"
MCP->>Stderr: "Started Shuttle MCP server!"
User->>MCP: "MCP tool call request"
MCP->>Tools: "tool function (e.g., deploy, logs, project_list)"
Note over Tools,Stderr: Each tool call is instrumented with tracing
Tools->>Stderr: "Running tool debug event"
Tools->>Tools: "execute_command()"
Tools->>MCP: "tool result"
MCP->>User: "tool response"
Note over User,Stderr: All tracing output goes to stderr for better separation from main output
8 files reviewed, no comments
Uh oh!
There was an error while loading. Please reload this page.