MCPcopy Create free account
hub / github.com/IBM/mcp-cli / create_runtime_patch

Function create_runtime_patch

diagnostics/timeout_investigation.py:138–176  ·  view source on GitHub ↗

Create a runtime patch to override the timeout.

()

Source from the content-addressed store, hash-verified

136
137
138def create_runtime_patch():
139 """Create a runtime patch to override the timeout."""
140 print("\n🔧 Creating runtime patch...")
141
142 patch_code = """
143# Runtime patch for MCP CLI timeout
144import os
145
146# Set environment variables that might be checked
147os.environ["MCP_TOOL_TIMEOUT"] = "300"
148os.environ["CHUK_TOOL_TIMEOUT"] = "300"
149os.environ["DEFAULT_TIMEOUT"] = "300"
150
151# Try to monkey patch common timeout locations
152try:
153 from chuk_tool_processor.execution.strategies.inprocess_strategy import InProcessStrategy
154
155 # Store original __init__
156 _original_init = InProcessStrategy.__init__
157
158 def patched_init(self, registry, max_concurrency=None, default_timeout=300.0, **kwargs):
159 print(f"🔧 InProcessStrategy patched: timeout={default_timeout}")
160 return _original_init(self, registry, max_concurrency=max_concurrency,
161 default_timeout=default_timeout, **kwargs)
162
163 InProcessStrategy.__init__ = patched_init
164 print("✅ Successfully patched InProcessStrategy")
165
166except Exception as e:
167 print(f"❌ Failed to patch InProcessStrategy: {e}")
168
169# Save this as patch.py and import it before running MCP CLI
170"""
171
172 with open("mcp_timeout_patch.py", "w") as f:
173 f.write(patch_code)
174
175 print("✅ Created mcp_timeout_patch.py")
176 print(" Usage: python -c 'import mcp_timeout_patch' && mcp-cli chat")
177
178
179if __name__ == "__main__":

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected