Skip to content

Commit 331b8b2

Browse files
rootclaude
andcommitted
fix: prevent exception information exposure in MCP server
🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent d600180 commit 331b8b2

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/mcp_server/main.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ async def ingest_repository(
8080

8181
except Exception as e:
8282
logger.error(f"Error during ingestion: {e}", exc_info=True)
83-
return f"Error ingesting repository: {e!s}"
83+
return "Error ingesting repository: An internal error occurred"
8484

8585

8686
async def start_mcp_server_tcp(host: str = "0.0.0.0", port: int = 8001):
@@ -181,13 +181,14 @@ async def handle_message(message: dict):
181181
},
182182
)
183183
except Exception as e:
184+
logger.error(f"Tool execution failed: {e}", exc_info=True)
184185
return JSONResponse(
185186
{
186187
"jsonrpc": "2.0",
187188
"id": message.get("id"),
188189
"error": {
189190
"code": -32603,
190-
"message": f"Tool execution failed: {e!s}",
191+
"message": "Tool execution failed",
191192
},
192193
},
193194
)
@@ -224,7 +225,7 @@ async def handle_message(message: dict):
224225
"id": message.get("id") if "message" in locals() else None,
225226
"error": {
226227
"code": -32603,
227-
"message": f"Internal error: {e!s}",
228+
"message": "Internal server error",
228229
},
229230
},
230231
)

0 commit comments

Comments
 (0)