Skip to content

Extract MCP timeout constants for maintainability#6692

Merged
pelikhan merged 4 commits intomainfrom
copilot/extract-mcp-timeout-constants
Dec 17, 2025
Merged

Extract MCP timeout constants for maintainability#6692
pelikhan merged 4 commits intomainfrom
copilot/extract-mcp-timeout-constants

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Dec 17, 2025

Consolidates hardcoded timeout values (10s connect, 5s operations, 30m HTTP) into named constants to improve maintainability and consistency across MCP client code.

Changes

  • Added constants in pkg/cli/mcp_inspect_mcp.go:

    • MCPConnectTimeout (10s) - MCP server connection establishment
    • MCPOperationTimeout (5s) - ListTools/ListResources operations
    • MCPServerHTTPTimeout (30m) - HTTP server session timeout
  • Replaced hardcoded values:

    • 6 instances in connectStdioMCPServer and connectHTTPMCPServer
    • Added ReadHeaderTimeout to HTTP server config in mcp_server.go
// Before
connectCtx, cancel := context.WithTimeout(ctx, 10*time.Second)

// After
connectCtx, cancel := context.WithTimeout(ctx, MCPConnectTimeout)

All timeout values remain functionally unchanged.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/user
    • Triggering command: /usr/bin/gh gh api user --jq .login -json GO111MODULE ache/go/1.25.0/x64/bin/go GOINSECURE GOMOD GOMODCACHE go env it/ref/tags/v5 GO111MODULE /opt/hostedtoolcache/go/1.25.0/x64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh api user --jq .login GmkEpiFk4 GO111MODULE 3575698/b347=> GOINSECURE GOMOD -d/gh-aw go ortc�� .git stmain.go noffline GOINSECURE GOMOD GOMODCACHE noffline (http block)
    • Triggering command: /usr/bin/gh gh api user --jq .login /run/containerd/io.containerd.runtime.v2.task/moby/b073249c18aed80908ce3ba76b888163c4be1e100cbae57837652be6cccfe26e/init.pid b073249c18aed80908ce3ba76b888163c4be1e100cbae57837652be6cccfe26e 1/x64/bin/node 163c4be1e100cbae57837652be6cccfe26e/log.json GOMOD GOMODCACHE ache/go/1.25.0/x--json env 92/push_to_pull_request_branch.j/run/containerd/io.containerd.runtime.v2.task/moby/6701175663d14bash GO111MODULE 3575698/b383=> GOINSECURE GOMOD GOMODCACHE go (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>[plan] Extract MCP timeout constants for maintainability</issue_title>
<issue_description>## Objective

Consolidate magic timeout values into named constants for easier maintenance and consistency.

Context

MCP client code uses hardcoded timeout values in multiple locations:

  • 10 seconds for connection timeout
  • 5 seconds for operation timeout
  • 30 minutes for HTTP server session timeout (after adding in previous task)

Approach

  1. Define timeout constants in pkg/cli/mcp_inspect_mcp.go:
const (
    MCPConnectTimeout    = 10 * time.Second
    MCPOperationTimeout  = 5 * time.Second
    MCPServerHTTPTimeout = 30 * time.Minute
)
  1. Replace hardcoded values with constants throughout the codebase

Files to Modify

  • pkg/cli/mcp_inspect_mcp.go (lines ~131, 154, 167, 246)
  • pkg/cli/mcp_server.go (line ~767)

Acceptance Criteria

AI generated by Plan Command for discussion #6658

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 3 commits December 17, 2025 01:38
Co-authored-by: mnkiefer <8320933+mnkiefer@users.noreply.github.com>
Co-authored-by: mnkiefer <8320933+mnkiefer@users.noreply.github.com>
Co-authored-by: mnkiefer <8320933+mnkiefer@users.noreply.github.com>
Copilot AI changed the title [WIP] Extract MCP timeout constants for better maintainability Extract MCP timeout constants for maintainability Dec 17, 2025
Copilot AI requested a review from mnkiefer December 17, 2025 01:51
@pelikhan pelikhan marked this pull request as ready for review December 17, 2025 04:18
@pelikhan pelikhan merged commit fce5046 into main Dec 17, 2025
4 checks passed
@pelikhan pelikhan deleted the copilot/extract-mcp-timeout-constants branch December 17, 2025 04:19
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.

[plan] Extract MCP timeout constants for maintainability

3 participants