[Bug]: CLI MCP generator omits MCP-Protocol-Version after initialization

Open Beginner friendly
#4,343 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
77/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
go
Domain
api, cli

Research direction

Read cli/src/internal/mcp/generator.go, especially the subsequent request header construction near line 219 and initialization response handling near line 305. Follow how the negotiated protocol version and session ID move through the generator, then add coverage for a stateless endpoint that requires the header. Done means post-initialization requests send the negotiated version while caller-supplied authentication headers still work.

Written by the indexing model from the issue text.

Description

Aspect/AI Aspect/API. Severity/Major
Description

ap gateway mcp generate in WSO2 API Platform CLI ap v0.9.1 proposes MCP protocol version 2025-06-18 during initialization but does not send the MCP-Protocol-Version HTTP header on subsequent requests.

A local stateless server that advertises that version and requires the version header rejects discovery. Supplying the same header manually with the CLI's --header option makes the identical discovery sequence succeed.

Steps to Reproduce
  1. Download and extract the official CLI release ap/v0.9.1.

  2. Download reproduce_mcp.py (Python standard library only).

  3. Run:

    python reproduce_mcp.py --binary /absolute/path/to/ap --case protocol_header --case protocol_header_control
    

    On Windows use --binary "C:\tools\ap.exe" and python or py as appropriate.

The first fixture returns a successful initialize result with protocolVersion: 2025-06-18, issues no session ID, and requires MCP-Protocol-Version: 2025-06-18 on later POSTs; otherwise it returns HTTP 400 with a JSON-RPC error. The control case uses the same fixture and only adds --header "MCP-Protocol-Version: 2025-06-18" to the CLI command.

Actual result
Case CLI exit Echo tool in output MCP-Protocol-Version sent
protocol_header 1 No Missing on every post-initialization request
protocol_header_control 0 Yes 2025-06-18 on every request

Failing case stderr:

Error: tools/list request returned an error: Unsupported protocol version: missing MCP-Protocol-Version

The captured request log shows protocol_header: null for initialize, notifications/initialized, tools/list, prompts/list and resources/list in the failing case, and 2025-06-18 for all five in the control case.

Expected result

The CLI should retain the version negotiated during initialization and attach it to subsequent HTTP protocol requests automatically, while preserving any caller-supplied authentication headers. The MCP protocol-version header requirement applies to post-initialization requests; a stateless server cannot recover the version from a session ID.

Source evidence and suggested direction

Carry the negotiated version alongside the session ID and set the header for later protocol requests. Add coverage with a stateless endpoint that requires the header.

Environment Details
  • Product/component: WSO2 API Platform CLI, official Linux amd64 release ap/v0.9.1 (ap version v0.9.1 (built at 2026-08-07T09:04:19Z)).
  • Test runtime: Linux 6.18.57 x86_64 with glibc 2.41, Python 3.12.14.
  • Source reviewed: api-platform main at 398d50772b5605ffe0d6d8693aa7b9ce7c84032e; inspected, not compiled or executed.
  • All fixtures advertise tools, prompts, resources and logging capabilities, so the separately reported optional-capability issue does not apply here.
  • Evidence boundary: local mock server only; not tested against a WSO2-hosted product instance. No CVSS score is asserted.
Area / Aspect / Severity

Area: CLI. Aspect: Aspect/AI and Aspect/API. Severity: Severity/Major (provisional functional assessment for maintainer review).

Screenshot and attachments

Screenshot of captured CLI output and request headers for the protocol-version cases

Dominant language
Go
Stars
85
Forks
137
Avg merge
1d 12h
Merged PRs (30d)
247

Getting set up

  • No Dockerfile or Docker Compose file
  • Has a pull request template
  • No contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from wso2/api-platform

All issues in wso2/api-platform

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.