Skip to content

feat(mcp): logs on stderr, improve args#2083

Merged
jonaro00 merged 3 commits intomainfrom
mcp-stderr-logs
Sep 11, 2025
Merged

feat(mcp): logs on stderr, improve args#2083
jonaro00 merged 3 commits intomainfrom
mcp-stderr-logs

Conversation

@jonaro00
Copy link
Member

@jonaro00 jonaro00 commented Jul 4, 2025

  • CLI tracing sub writes to stderr
  • add instrumentation + tracing event for each tool call (prints to stderr)
  • simplify project list args, always run in current dir (shouldn't matter)

@jonaro00 jonaro00 marked this pull request as ready for review September 9, 2025 20:50
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

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
Loading

8 files reviewed, no comments

Edit Code Review Bot Settings | Greptile

jonaro00 and others added 2 commits September 10, 2025 15:12
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
@jonaro00 jonaro00 merged commit 2d8a2bd into main Sep 11, 2025
0 of 24 checks passed
@jonaro00 jonaro00 deleted the mcp-stderr-logs branch September 11, 2025 10:25
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