Skip to content

Commit ab9021a

Browse files
committed
Merge branch 'feature/update_mcp_spec' into 'master'
Update mcp server to match newest spec See merge request ae_group/esp-iot-solution!1500
2 parents c29b004 + fe61e8d commit ab9021a

96 files changed

Lines changed: 24660 additions & 1408 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,3 +128,8 @@ output.json
128128
**/dist/
129129

130130
*.log
131+
132+
# AI related files
133+
.cursor/
134+
.codex
135+
.gemini/

.gitlab/ci/target_test.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,8 @@ components_test_iot_usbh_cdc:
185185
- job: "build_components_usb_iot_usbh_cdc_test_apps"
186186
artifacts: true
187187
optional: false
188+
# High failure rate, cause TBD.
189+
allow_failure: true
188190
retry:
189191
max: 2
190192
parallel:

components/led/lightbulb_driver/include/lightbulb.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -432,93 +432,93 @@ typedef struct {
432432
bool interrupt_forbidden; /**< If true, the auto-stop timer can only be stopped by specific interfaces or FreeRTOS triggers. */
433433
} lightbulb_effect_config_t;
434434

435+
#ifdef CONFIG_ENABLE_PWM_DRIVER
435436
/**
436437
* @brief Create and initialize a PWM-based lightbulb device.
437438
*
438439
* @param config Pointer to lightbulb configuration
439440
* @return lightbulb_handle_t Lightbulb handle, or NULL on failure.
440441
*/
441-
#ifdef CONFIG_ENABLE_PWM_DRIVER
442442
lightbulb_handle_t lightbulb_new_pwm_device(lightbulb_config_t *config);
443443
#endif
444444

445+
#ifdef CONFIG_ENABLE_SM2182E_DRIVER
445446
/**
446447
* @brief Create and initialize a SM2182E-based lightbulb device.
447448
*
448449
* @param config Pointer to lightbulb configuration
449450
* @return lightbulb_handle_t Lightbulb handle, or NULL on failure.
450451
*/
451-
#ifdef CONFIG_ENABLE_SM2182E_DRIVER
452452
lightbulb_handle_t lightbulb_new_sm2182e_device(lightbulb_config_t *config);
453453
#endif
454454

455+
#ifdef CONFIG_ENABLE_SM2135EH_DRIVER
455456
/**
456457
* @brief Create and initialize a SM2135EH-based lightbulb device.
457458
*
458459
* @param config Pointer to lightbulb configuration
459460
* @return lightbulb_handle_t Lightbulb handle, or NULL on failure.
460461
*/
461-
#ifdef CONFIG_ENABLE_SM2135EH_DRIVER
462462
lightbulb_handle_t lightbulb_new_sm2135eh_device(lightbulb_config_t *config);
463463
#endif
464464

465+
#ifdef CONFIG_ENABLE_SM2x35EGH_DRIVER
465466
/**
466467
* @brief Create and initialize a SM2x35EGH-based lightbulb device.
467468
*
468469
* @param config Pointer to lightbulb configuration
469470
* @return lightbulb_handle_t Lightbulb handle, or NULL on failure.
470471
*/
471-
#ifdef CONFIG_ENABLE_SM2x35EGH_DRIVER
472472
lightbulb_handle_t lightbulb_new_sm2x35egh_device(lightbulb_config_t *config);
473473
#endif
474474

475+
#ifdef CONFIG_ENABLE_BP57x8D_DRIVER
475476
/**
476477
* @brief Create and initialize a BP57x8D-based lightbulb device.
477478
*
478479
* @param config Pointer to lightbulb configuration
479480
* @return lightbulb_handle_t Lightbulb handle, or NULL on failure.
480481
*/
481-
#ifdef CONFIG_ENABLE_BP57x8D_DRIVER
482482
lightbulb_handle_t lightbulb_new_bp57x8d_device(lightbulb_config_t *config);
483483
#endif
484484

485+
#ifdef CONFIG_ENABLE_BP1658CJ_DRIVER
485486
/**
486487
* @brief Create and initialize a BP1658CJ-based lightbulb device.
487488
*
488489
* @param config Pointer to lightbulb configuration
489490
* @return lightbulb_handle_t Lightbulb handle, or NULL on failure.
490491
*/
491-
#ifdef CONFIG_ENABLE_BP1658CJ_DRIVER
492492
lightbulb_handle_t lightbulb_new_bp1658cj_device(lightbulb_config_t *config);
493493
#endif
494494

495+
#ifdef CONFIG_ENABLE_KP18058_DRIVER
495496
/**
496497
* @brief Create and initialize a KP18058-based lightbulb device.
497498
*
498499
* @param config Pointer to lightbulb configuration
499500
* @return lightbulb_handle_t Lightbulb handle, or NULL on failure.
500501
*/
501-
#ifdef CONFIG_ENABLE_KP18058_DRIVER
502502
lightbulb_handle_t lightbulb_new_kp18058_device(lightbulb_config_t *config);
503503
#endif
504504

505+
#ifdef CONFIG_ENABLE_WS2812_DRIVER
505506
/**
506507
* @brief Create and initialize a WS2812-based lightbulb device.
507508
*
508509
* @param config Pointer to lightbulb configuration
509510
* @return lightbulb_handle_t Lightbulb handle, or NULL on failure.
510511
*/
511-
#ifdef CONFIG_ENABLE_WS2812_DRIVER
512512
lightbulb_handle_t lightbulb_new_ws2812_device(lightbulb_config_t *config);
513513
#endif
514514

515+
#ifdef CONFIG_ENABLE_SM16825E_DRIVER
515516
/**
516517
* @brief Create and initialize a SM16825E-based lightbulb device.
517518
*
518519
* @param config Pointer to lightbulb configuration
519520
* @return lightbulb_handle_t Lightbulb handle, or NULL on failure.
520521
*/
521-
#ifdef CONFIG_ENABLE_SM16825E_DRIVER
522522
lightbulb_handle_t lightbulb_new_sm16825e_device(lightbulb_config_t *config);
523523
#endif
524524

components/mcp-c-sdk/CHANGELOG.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,77 @@
11
# ChangeLog
22

3+
## [v2.0.0] - 2026-04-13
4+
5+
Targets **MCP protocol `2025-11-25`** as the default negotiated surface (with **legacy `2024-11-05`** transport still selectable via Kconfig where applicable). This release aligns the SDK with **Streamable HTTP** (JSON-RPC over HTTP + SSE), optional **OAuth** discovery metadata, richer **auth** options, and the **Prompts / Resources / Completions / Tasks** capability set.
6+
7+
### Added
8+
9+
#### Engine, tools, and capability modules
10+
11+
- **Prompts**: Register static or dynamic prompts; engine handles `prompts/list` and `prompts/get` with render callbacks (`esp_mcp_prompt.h`, `esp_mcp_prompt.c`).
12+
- **Resources**: Register resources with optional dynamic `read` callbacks; engine handles `resources/list`, `resources/templates/list`, and `resources/read` (`esp_mcp_resource.h`, `esp_mcp_resource.c`).
13+
- **Completions**: Optional completion provider wired to `completion/complete` (`esp_mcp_completion.h`, `esp_mcp_completion.c`).
14+
- **Tasks (experimental)**: Internal task store and lifecycle helpers (`esp_mcp_task.c` / `esp_mcp_task_priv.h`, not public API) supporting async `tools/call` flows and JSON-RPC **`tasks/list`**, **`tasks/get`**, **`tasks/result`**, **`tasks/cancel`** in the engine.
15+
- **Tools**: Expanded tool registration and execution paths to match updated MCP method behavior (including task-augmented `tools/call` where enabled).
16+
17+
#### HTTP server transport (`esp_mcp_http_server.c`)
18+
19+
- **Streamable HTTP**: MCP primary JSON-RPC on **`POST`**; **SSE** stream on **`GET`** with `Accept: text/event-stream` for server-initiated JSON-RPC notifications and downstream traffic.
20+
- **Sessions**: **`MCP-Session-Id`** header support, session registry, TTL / idle behavior (Kconfig), and session termination (**`DELETE`**) where configured.
21+
- **Protocol negotiation**: **`MCP-Protocol-Version`** response header and compatibility checks against client `Protocol-Version` / request headers.
22+
- **Authentication**: Transport-level **Bearer** token checks; optional **JWT** verification skeleton (claims, audience, issuer, time skew, optional **JWKS** / inline key material, optional **signature** path); **`WWW-Authenticate`** and scope-insufficient paths for OAuth-style clients.
23+
- **OAuth metadata**: HTTP handlers for **`.well-known/oauth-protected-resource`** and **`.well-known/oauth-authorization-server`** when enabled.
24+
- **CORS**: Optional staging of **`Access-Control-Allow-Origin`** and related headers for browser clients (with safe pointer lifetime handling vs `esp_http_server` header storage).
25+
- **Operational responses**: Structured HTTP status usage (e.g. **201/202** session creation, **406** unacceptable SSE, **503** overload), **`ping`** health, and clearer error bodies for JSON-RPC errors where applicable.
26+
- **SSE implementation**: Async client tasks, event IDs / sequencing, optional resume hints, queueing, and backpressure-related safeguards (see Kconfig for buffer sizes and task stack).
27+
28+
#### HTTP client transport (`esp_mcp_http_client.c`)
29+
30+
- **Streamable client**: Outbound **`POST`** for JSON-RPC; inbound **SSE** parsing for default `message` events and dispatch into the manager.
31+
- **Session & auth**: Track **`MCP-Session-Id`** from responses; apply **Authorization** headers; retry paths for **401/403** where implemented; align **`HTTP_EVENT_ON_FINISH`** handling so pending manager callbacks are not left unresolved on error statuses.
32+
33+
#### Manager (`esp_mcp_mgr.c`)
34+
35+
- **Request context**: Per-request session / routing context for tools, tasks, and notifications.
36+
- **Pending JSON-RPC**: Queue and completion of outbound/inbound requests so `tools/call`, `tasks/*`, and SSE-delivered messages resolve correctly.
37+
- **Integration**: Coordinates engine, transports, and task objects for **initialize**, **notifications**, **tools/***, **resources/***, **prompts/***, **completion/***, **tasks/***, and **logging** where exposed.
38+
39+
#### Tests (`components/mcp-c-sdk/test_apps`)
40+
41+
- **On-target**: Large expansion of `test_mcp_c_sdk.c` covering initialization, tools (list/call/pagination), resources, prompts, completions, tasks, auth gates, SSE behavior, and error codes.
42+
- **Host pytest**: `pytest_mcp.py` updates; new **`pytest_mcp_http_integration.py`** for HTTP-level checks against a running server.
43+
- **Runner**: **`run_test_apps.sh`** to drive builds and tests with multiple **`sdkconfig.ci.*`** profiles.
44+
- **CI profiles**: Dedicated **`sdkconfig.ci.*`** fragments for combinations such as **SSE on/off**, **auth on/off**, **JWT claims / signature**, **OAuth metadata on/off**, **protocol default 2024**, **session TTL**, **tool list/call limits**, missing HTTP client/server components, etc.
45+
- **Repository wiring**: Root **`pytest.ini`** and **`tools/ci/executable-list.txt`** updates so CI can discover and run the new scripts.
46+
47+
#### Documentation (`docs/`)
48+
49+
- **User guides (EN & ZH)**: New topic pages under `docs/en/mcp/` and `docs/zh_CN/mcp/`:
50+
- `core_and_manager.rst` — engine vs manager responsibilities
51+
- `tooling_and_data.rst` — tools and structured data
52+
- `prompt_resource_completion.rst` — prompts, resources, completions
53+
- **Overview**: `docs/en/ai/mcp.rst` and `docs/zh_CN/ai/mcp.rst` updated to link into the split structure.
54+
- **API reference**: `docs/Doxyfile` **INPUT** extended with **`esp_mcp_prompt.h`**, **`esp_mcp_resource.h`**, **`esp_mcp_completion.h`** (in addition to existing engine/mgr/tool/data/property headers).
55+
56+
#### Examples (`examples/mcp/`)
57+
58+
- **`mcp_client`**: Updated **`main/Kconfig`**, **`sdkconfig.defaults`**, **`partitions.csv`**, **`README.md`**, and **`mcp_client.c`** (initialize ordering, tools/list/call, optional resources/prompts demos, pagination); added **`README_CN.md`**.
59+
- **`mcp_server`**: Extended **`mcp_server.c`** and server **`Kconfig`**; **`sdkconfig.defaults`** and **`partitions.csv`**; expanded **`README.md`** and added **`README_CN.md`**.
60+
- **CI matrix**: **`examples/mcp/mcp_server/ci/sdkconfig.matrix/*.defaults`** — many named presets (baseline SSE/auth, JWT variants, JWKS valid/invalid, metadata off, TTL short, health endpoint unavailable, GET **405**, server-only mode, etc.).
61+
- **Scripts**: **`test_kconfig_matrix.sh`** (matrix validation), **`test_sse_e2e.sh`** (SSE end-to-end), **`gen_es256_test_materials.sh`** (JWT test key material for CI).
62+
63+
### Changed
64+
65+
- **HTTP server & client**: Major internal redesign of **`esp_mcp_http_server.c`** and **`esp_mcp_http_client.c`** for Streamable HTTP, session lifecycle, SSE, and auth—file size and behavior differ substantially from v1.0.x line-oriented server-only usage.
66+
- **Engine**: **`esp_mcp_engine.c`** grown to implement the full method surface (including tasks and streaming-related notifications) and stricter protocol checks.
67+
- **Manager**: **`esp_mcp_mgr.c`** expanded for session-aware routing, pending RPC bookkeeping, and transport callbacks; callers should re-validate threading and callback assumptions.
68+
69+
### Upgrade / migration
70+
71+
- Re-test any custom **HTTP** integration: **SSE**, **`MCP-Session-Id`**, and **auth** headers change observable wire behavior.
72+
- If you relied only on **simple POST JSON-RPC** without sessions or SSE, enable or mock the corresponding Kconfig options and verify server logs and client sequencing (**`initialize`** must complete before **`tools/list`** / **`tools/call`** in strict clients).
73+
- Run the updated **`test_apps`** and, where possible, **`pytest_mcp_http_integration`** against your deployment before production rollout.
74+
375
## [v1.0.0]
476

577
### Added

components/mcp-c-sdk/CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,13 @@ set(srcs
44
"src/esp_mcp_property.c"
55
"src/esp_mcp_tool.c"
66
"src/esp_mcp_data.c"
7+
"src/esp_mcp_resource.c"
8+
"src/esp_mcp_prompt.c"
9+
"src/esp_mcp_completion.c"
10+
"src/esp_mcp_task.c"
711
)
812

9-
set(priv_req "esp_common" "app_update" "json" "esp_http_server" "esp_http_client" "http_parser")
13+
set(priv_req "esp_common" "app_update" "json" "esp_http_server" "esp_http_client" "http_parser" "esp_timer" "mbedtls")
1014

1115
# Conditionally compile built-in HTTP transport
1216
if(CONFIG_MCP_TRANSPORT_HTTP_SERVER)

0 commit comments

Comments
 (0)