Skip to content

Conversation

@pro-vi
Copy link
Contributor

@pro-vi pro-vi commented Dec 9, 2025

Summary

The timeout field was defined in McpHttpServerSchema but never actually used in the implementation. _withSession() had a hardcoded 15000ms (15s) timeout which caused issues with slow MCP servers (e.g., LLM providers like PAL via OpenRouter that need 30-60s+ for responses).

Changes

  • Add timeout field to McpStdioServerSchema for consistency with HTTP servers
  • Use serverConfig.timeout in _withSession() instead of hardcoded 15s
  • Default timeout increased from 15s to 30s to match the existing schema default

Before

// Hardcoded 15s timeout, ignoring config
new Promise<T>((_, reject) => setTimeout(() => reject(...), 15000))

After

const timeoutMs = (serverConfig.timeout ?? 30) * 1000;
new Promise<T>((_, reject) => setTimeout(() => reject(...), timeoutMs))

Usage

Users can now configure timeout per-server in their .utcp_config.json:

{
  "manual_call_templates": [{
    "name": "pal",
    "call_template_type": "mcp",
    "config": {
      "mcpServers": {
        "pal": {
          "transport": "stdio",
          "command": "...",
          "timeout": 120
        }
      }
    }
  }]
}

Related Issues

Fixes universal-tool-calling-protocol/code-mode#20


Summary by cubic

Use the configured MCP timeout instead of a hardcoded 15s to avoid premature failures with slow MCP servers. Default is 30s; set per-server timeouts in .utcp_config.json (fixes code-mode #20).

  • Bug Fixes
    • Respect serverConfig.timeout in _withSession() (including retry path).
    • Add timeout to McpStdioServerSchema for parity with HTTP servers.

Written for commit 9a3a7a5. Summary will update automatically on new commits.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 2 files

Prompt for AI agents (all 1 issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="packages/mcp/src/mcp_communication_protocol.ts">

<violation number="1" location="packages/mcp/src/mcp_communication_protocol.ts:178">
P2: The timeout expression `serverConfig.timeout ?? 30` is duplicated. Consider using `${timeoutMs / 1000}s` in the error message instead, which references the already-calculated value and ensures consistency.</violation>
</file>

Since this is your first cubic review, here's how it works:

  • cubic automatically reviews your code and comments on bugs and improvements
  • Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
  • Ask questions if you need clarification on any suggestion

Reply to cubic to teach it or ask questions. Re-run a review with @cubic-dev-ai review this PR

The `timeout` field was defined in `McpHttpServerSchema` but never used.
`_withSession()` had a hardcoded 15000ms timeout which caused issues with
slow MCP servers (e.g., LLM providers via OpenRouter).

Changes:
- Add `timeout` field to `McpStdioServerSchema` for consistency
- Use `serverConfig.timeout` in `_withSession()` instead of hardcoded 15s
- Default timeout increased from 15s to 30s to match schema default

Fixes #20 in code-mode repo
@pro-vi pro-vi force-pushed the fix/configurable-mcp-timeout branch from c966bcb to 9a3a7a5 Compare December 9, 2025 07:57
@h3xxit h3xxit changed the base branch from main to dev December 10, 2025 08:44
@h3xxit
Copy link
Member

h3xxit commented Dec 10, 2025

Thank you for the PR, makes a lot of sense. If you want to get added to our contributors page https://www.utcp.io/about/about-us please tell me your name and any links you want added. Feel free to also join our discord server if youre not already there.

@h3xxit h3xxit merged commit 134a3eb into universal-tool-calling-protocol:dev Dec 10, 2025
pro-vi added a commit to pro-vi/code-mode that referenced this pull request Dec 12, 2025
@utcp/mcp@1.1.0+ includes the fix for configurable MCP operation timeout
(universal-tool-calling-protocol/typescript-utcp#15).

Without this bump, code-mode-mcp stays pinned to 1.0.x which has a
hardcoded 15s timeout that breaks slow MCP tools (e.g., LLM providers
via OpenRouter that need 30-60s+).

Users can now set `timeout` in their UTCP config to override the default.
@pro-vi
Copy link
Contributor Author

pro-vi commented Dec 14, 2025

@h3xxit We also need to merge this PR universal-tool-calling-protocol/code-mode#23 which bumps the deps so this fix will work in codemode.

Feel free to include Provi + my github in the about page. Thx :)

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.

Tool Timeout Persists Despite Increased MCP Timeout Settings

2 participants