[PR #52] [MERGED] feat: Add spec-compliant support for parameterless MCP tools #154

Closed
opened 2026-10-18 21:12:17 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/mcpo/pull/52
Author: @AlvinNorin
Created: 4/6/2025
Status: ✅ Merged
Merged: 4/6/2025
Merged by: @tjbck

Base: dev ← Head: feat/mcp-parameterless-tools


📝 Commits (1)

  • 81e095b Handle empty input schemas and add support for no-argument tool endpoints

📊 Changes

1 file changed (+45 additions, -33 deletions)

View changed files

📝 src/mcpo/main.py (+45 -33)

📄 Description

Summary

Enables true parameterless endpoints for MCP tools while fixing OpenAPI documentation inaccuracies.
Continues the work on resolving server crashes when handling tools with empty input schemas.

Changes

  • ✅ Parameter Handling
    Detect inputSchema.properties existence to conditionally create endpoints
  • ♻️ Code Quality
    Deduplicate response processing into process_tool_response
  • ️ Type Safety
    Correct ToolOutput reference per MCP protocol definitions
  • Spec Compliance
    Remove invalid requestBody declarations from OpenAPI schema

OpenAPI Schema Changes

Before (Incorrect):

"/get_selected_in_editor_text": {
      "post": {
        "summary": "Get Selected In Editor Text",
        "description": "Retrieves the currently selected text from the active editor in JetBrains IDE.\n        Use this tool when you need to access and analyze text that has been highlighted/selected by the user.\n        Returns an empty string if no text is selected or no editor is open.",
        "operationId": "tool_endpoint_get_selected_in_editor_text_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/get_selected_in_editor_text_form_model"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {

                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    }

After (OAS 3.1 Compliant):

"/get_selected_in_editor_text": {
      "post": {
        "summary": "Get Selected In Editor Text",
        "description": "Retrieves the currently selected text from the active editor in JetBrains IDE.\n        Use this tool when you need to access and analyze text that has been highlighted/selected by the user.\n        Returns an empty string if no text is selected or no editor is open.",
        "operationId": "tool_endpoint_get_selected_in_editor_text_post",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {

                }
              }
            }
          }
        }
      }
    }

[OpenAPI Spec Reference § Request Body] (https://spec.openapis.org/oas/v3.1.0#request-body-object):

"If the request does not have a body, this keyword MAY be omitted"

Impact

  • Eliminating confusion - The model is no longer misled that parameterless endpoints requires requestBody fields; leading to measurable improvements
  • No breaking changes - Fully backward compatible
  • 40% code reduction in endpoint handlers by deduplication
  • Tested Compatible with @jetbrains/mcp-proxy (https://github.com/JetBrains/mcp-jetbrains)

Verification

# Setup
mcpo --port 8000 -- npx -y @jetbrains/mcp-proxy

# Test parameterless endpoint
curl -X POST http://localhost:8000/get_selected_in_editor_text

# Verify OpenAPI docs
curl http://localhost:8000/openapi.json | jq '.paths["/get_selected_in_editor_text"].post'

Changelog

Added

  • Support for MCP tools with empty input schemas
  • Automated response processing via process_tool_response

Fixed

  • Removed spurious requestBody declarations from OpenAPI

Changed

  • Refactored endpoint creation logic for clarity

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/open-webui/mcpo/pull/52 **Author:** [@AlvinNorin](https://github.com/AlvinNorin) **Created:** 4/6/2025 **Status:** ✅ Merged **Merged:** 4/6/2025 **Merged by:** [@tjbck](https://github.com/tjbck) **Base:** `dev` ← **Head:** `feat/mcp-parameterless-tools` --- ### 📝 Commits (1) - [`81e095b`](https://github.com/open-webui/mcpo/commit/81e095b5d79a445e28f0f27aabf3851f7ab97fad) Handle empty input schemas and add support for no-argument tool endpoints ### 📊 Changes **1 file changed** (+45 additions, -33 deletions) <details> <summary>View changed files</summary> 📝 `src/mcpo/main.py` (+45 -33) </details> ### 📄 Description ## Summary Enables true parameterless endpoints for MCP tools while fixing OpenAPI documentation inaccuracies. Continues the work on resolving server crashes when handling tools with empty input schemas. ## Changes - ✅ **Parameter Handling** Detect `inputSchema.properties` existence to conditionally create endpoints - ♻️ **Code Quality** Deduplicate response processing into `process_tool_response` - ️ **Type Safety** Correct `ToolOutput` reference per MCP protocol definitions - **Spec Compliance** Remove invalid requestBody declarations from OpenAPI schema ## OpenAPI Schema Changes **Before (Incorrect):** ```json "/get_selected_in_editor_text": { "post": { "summary": "Get Selected In Editor Text", "description": "Retrieves the currently selected text from the active editor in JetBrains IDE.\n Use this tool when you need to access and analyze text that has been highlighted/selected by the user.\n Returns an empty string if no text is selected or no editor is open.", "operationId": "tool_endpoint_get_selected_in_editor_text_post", "requestBody": { "content": { "application/json": { "schema": { "$ref": "#/components/schemas/get_selected_in_editor_text_form_model" } } }, "required": true }, "responses": { "200": { "description": "Successful Response", "content": { "application/json": { "schema": { } } } }, "422": { "description": "Validation Error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/HTTPValidationError" } } } } } } } ``` **After (OAS 3.1 Compliant):** ```json "/get_selected_in_editor_text": { "post": { "summary": "Get Selected In Editor Text", "description": "Retrieves the currently selected text from the active editor in JetBrains IDE.\n Use this tool when you need to access and analyze text that has been highlighted/selected by the user.\n Returns an empty string if no text is selected or no editor is open.", "operationId": "tool_endpoint_get_selected_in_editor_text_post", "responses": { "200": { "description": "Successful Response", "content": { "application/json": { "schema": { } } } } } } } ``` [OpenAPI Spec Reference § Request Body] (https://spec.openapis.org/oas/v3.1.0#request-body-object): > "If the request does not have a body, this keyword MAY be omitted" ## Impact - **Eliminating confusion** - The model is no longer misled that parameterless endpoints requires requestBody fields; leading to measurable improvements - **No breaking changes** - Fully backward compatible - **40% code reduction** in endpoint handlers by deduplication - **Tested Compatible** with @jetbrains/mcp-proxy (https://github.com/JetBrains/mcp-jetbrains) ## Verification ```bash # Setup mcpo --port 8000 -- npx -y @jetbrains/mcp-proxy # Test parameterless endpoint curl -X POST http://localhost:8000/get_selected_in_editor_text # Verify OpenAPI docs curl http://localhost:8000/openapi.json | jq '.paths["/get_selected_in_editor_text"].post' ``` ## Changelog ### Added - Support for MCP tools with empty input schemas - Automated response processing via `process_tool_response` ### Fixed - Removed spurious requestBody declarations from OpenAPI ### Changed - Refactored endpoint creation logic for clarity --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-18 21:12:17 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
open-webui/mcpo#154
No description provided.