8000 add response code validations for mcp request by nayanakto · Pull Request #2737 · akto-api-security/akto · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

add response code validations for mcp request #2737

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 30, 2025

Conversation

nayanakto
Copy link
Contributor

No description provided.

@Copilot Copilot AI review requested due to automatic review settings June 30, 2025 11:11
Copy link
Contributor
@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR enhances MCP response handling by validating HTTP status codes and updates corresponding tests.

  • Added a default 200 status code in the response helper method
  • Refactored testNullPayload to verify URL propagation instead of expecting an exception
  • Cleaned up URL assignment in the test
Comments suppressed due to low confidence (2)

libs/utils/src/test/java/com/akto/mcp/McpRequestResponseUtilsTest.java:119

  • Consider adding a test for non-2xx statusCode (e.g., 404) to verify that parseMcpResponseParams correctly throws an exception when the response code is outside the valid range.
        Assertions.assertEquals(url, afterMcp.getRequestParams().getURL());

libs/utils/src/test/java/com/akto/mcp/McpRequestResponseUtilsTest.java:115

  • The responseParams in testNullPayload has no statusCode set, so it may default to an invalid code. Add responseParams.statusCode = 200; (or use the setter) before parsing to align with valid response scenarios.
        HttpResponseParams responseParams = new HttpResponseParams();

@@ -26,6 +26,7 @@ private HttpResponseParams createHttpResponseParams(String payload, String url)

HttpResponseParams responseParams = new HttpResponseParams();
responseParams.setRequestParams(reqParams);
responseParams.statusCode = 200;
Copy link
Preview
Copilot AI Jun 30, 2025

Choose a reason for hiding this comment

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

[nitpick] Use the provided setter (e.g., responseParams.setStatusCode(200)) instead of directly accessing the statusCode field to maintain encapsulation and consistency.

Suggested change
responseParams.statusCode = 200;
responseParams.setStatusCode(200);

Copilot uses AI. Check for mistakes.

@notshivansh notshivansh merged commit 7b45b2c into feature/mini-runtime-release Jun 30, 2025
4 checks passed
@nayanakto nayanakto deleted the fb-mini-runtime-mcp-fix branch June 30, 2025 11: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.

2 participants
0