Skip to content

feat: add MCP server for AI agent device discovery#1418

Open
jajajhhz wants to merge 7 commits intomainfrom
feat/shifu-mcp-server
Open

feat: add MCP server for AI agent device discovery#1418
jajajhhz wants to merge 7 commits intomainfrom
feat/shifu-mcp-server

Conversation

@jajajhhz
Copy link
Copy Markdown
Collaborator

Summary

  • MCP Server (pkg/mcp/server/) — Streamable HTTP server exposing list_devices and get_device_desc tools for AI agents to discover IoT devices and their interaction contracts
  • Device API library (pkg/deviceapi/) — reusable Go library for EdgeDevice CR → Service/ConfigMap resolution
  • Fix: Service name resolution now uses label-selector-based lookup instead of assuming deployment name equals service name (addresses review comment from feat: add MCP server for AI agent device discovery #1410)
  • 22 tests — unit tests, in-memory transport tests, and E2E tests over real Streamable HTTP

Depends on #1417 (CRD field additions). Will retarget to main after #1417 merges.

Key changes from original #1410

Test plan

  • go test ./pkg/deviceapi/... — 9 tests pass (API + ConfigMap parsing + service resolution)
  • go test ./pkg/mcp/server/... — 13 tests pass (unit + E2E over Streamable HTTP)
  • Service resolution handles both naming conventions (with/without -deployment suffix)

🤖 Generated with Claude Code

…eShifu instructions

Add optional fields for AI agent consumption and device documentation:
- EdgeDeviceSpec: description, connectionInfo (free-form markdown)
- DeviceShifuInstruction: description, readWrite (R/W/RW), safe (bool)

Regenerate shifu_install.yml to include new CRD fields.
Update all existing device examples with the new metadata fields.
Add mcp-demo example YAMLs showcasing full field usage.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Cover the Description and ConnectionInfo deepcopy paths in
zz_generated.deepcopy.go to satisfy codecov patch coverage.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@jajajhhz jajajhhz force-pushed the feat/shifu-mcp-server branch from aecf8c8 to bbc8f9e Compare March 23, 2026 07:10
jajajhhz and others added 3 commits March 24, 2026 16:43
…rite, rename safe, move connectionInfo

Address @tomqin93's review comments on PR #1417:

1. Remove unused argumentPropertyList (DeviceShifuInstructionProperty) — was only
   used for logging. Fix nil pointer bug in MQTT config exposed by removal.
2. Make ReadWrite a typed enum (ReadWriteMode) with R/W/RW constants.
3. Replace ambiguous `safe` bool with `hasSideEffects` (bool) + `riskLevel` enum
   (RequireAttention, RequireConfirmation, RequireManagerConsent).
4. Move connectionInfo from EdgeDevice CRD to ConfigMap — non-HTTP protocols
   (MQTT, NATS) need broker/connection info that instructions alone don't convey.

Regenerated CRD manifests and shifu_install.yml.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ction fields

Address follow-up review:
- Move connectionInfo back to EdgeDevice CRD (endpoint URLs are per-device,
  can't be shared via ConfigMap). Strip device-specific URLs from content —
  only protocol-level connection patterns (auth, QoS, encoding).
- Remove hasSideEffects and riskLevel from DeviceShifuInstruction — safety
  can be inferred from ReadWrite mode + description. Keep only ReadWrite
  (typed enum) and Description.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Update spec to reflect:
- connectionInfo stays on EdgeDevice CRD, no device-specific URLs
- Remove safe/hasSideEffects/riskLevel — safety inferred from readWrite + description
- Remove argumentPropertyList references
- ReadWrite is now a typed enum (ReadWriteMode)
- Update all JSON response examples and YAML examples

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Base automatically changed from feat/crd-device-metadata to main March 25, 2026 06:32
jajajhhz and others added 2 commits March 25, 2026 14:33
Add Streamable HTTP MCP server exposing list_devices and get_device_desc
tools for AI coding agents to discover IoT devices and understand their
interaction contracts.

Components:
- pkg/deviceapi/ — reusable Go library for EdgeDevice CR, Deployment,
  Service, and ConfigMap resolution
- pkg/mcp/server/ — MCP server implementation with 22 tests
- cmd/shifu-mcp-server/ — binary entry point
- dockerfiles/Dockerfile.mcpServer — container image

Fix service name resolution: use label-selector-based Service lookup
instead of assuming deployment name equals service name.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Remove Safe field from Interaction type and all test assertions.
Cast ReadWriteMode to string in configmap parser.
Update all test ConfigMap YAML fixtures to remove safe: fields.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@jajajhhz jajajhhz force-pushed the feat/shifu-mcp-server branch from bbc8f9e to 6ddf494 Compare March 25, 2026 06:40
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 25, 2026

Codecov Report

❌ Patch coverage is 80.18868% with 42 lines in your changes missing coverage. Please review.
✅ Project coverage is 37.20%. Comparing base (f37547d) to head (6ddf494).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
pkg/mcp/server/server.go 76.00% 14 Missing and 4 partials ⚠️
pkg/deviceapi/resolver.go 77.35% 7 Missing and 5 partials ⚠️
pkg/deviceapi/api.go 83.05% 6 Missing and 4 partials ⚠️
pkg/deviceapi/configmap.go 86.66% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1418      +/-   ##
==========================================
+ Coverage   34.81%   37.20%   +2.38%     
==========================================
  Files          54       58       +4     
  Lines        4027     4231     +204     
==========================================
+ Hits         1402     1574     +172     
- Misses       2479     2489      +10     
- Partials      146      168      +22     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

3 participants