Skip to content

Feat/mcp mock mode#236

Closed
jlouvel wants to merge 7 commits intomainfrom
feat/mcp-mock-mode
Closed

Feat/mcp mock mode#236
jlouvel wants to merge 7 commits intomainfrom
feat/mcp-mock-mode

Conversation

@jlouvel
Copy link
Copy Markdown
Contributor

@jlouvel jlouvel commented Apr 3, 2026

Related Issue

Closes #189


What does this PR do?

Adds mock mode to the MCP server adapter, allowing MCP tools to return static const-valued outputs without consuming any upstream HTTP API.

Schema — Adds MockOutputParameter (name + type + const) to naftiko-schema.json, accepted when a tool declares no call or steps.

Engine — Extracts MockResponseBuilder from ResourceRestlet to build static responses from const-valued output parameters. ToolHandler detects mock tools (no call/steps) and delegates to MockResponseBuilder instead of the HTTP pipeline.

Docs & wiki — Updates Specification-Schema, FAQ (new entry), Roadmap, Guide-Use-Cases (key features for all 9 use cases), design-guidelines, and wrap-api-as-mcp skill reference.

Example — Adds mock-mcp.yml to schemas/examples/ demonstrating a standalone mock MCP capability.


Tests

  • MockResponseBuilderTest — unit tests for static response building from const-valued output parameters (string, number, boolean, object, array, nested)
  • MockMcpIntegrationTest — end-to-end integration test loading mock-mcp-capability.yaml fixture and exercising the full MCP mock tool chain
  • ToolHandlerTest — extended with mock-mode detection and delegation scenarios
  • ResourceRestletTest — updated after extracting MockResponseBuilder

Checklist

  • CI is green (build, tests, schema validation, security scans)
  • Rebased on latest main
  • Small and focused — one concern per PR
  • Commit messages follow Conventional Commits

Agent Context (optional)

agent_name: GitHub Copilot
llm: Claude Opus 4.6
tool: VS Code Chat
confidence: high
source_event: "#189"
discovery_method: user_report
review_focus: MockResponseBuilder.java, ToolHandler.java, naftiko-schema.json (MockOutputParameter)

@jlouvel jlouvel requested a review from eskenazit April 3, 2026 18:38
@eskenazit
Copy link
Copy Markdown
Contributor

@jlouvel there are conflicts in the branch, can you please solve them for review?

@jlouvel jlouvel force-pushed the feat/mcp-mock-mode branch from 67336a6 to 99a3eab Compare April 7, 2026 14:22
@jlouvel
Copy link
Copy Markdown
Contributor Author

jlouvel commented Apr 7, 2026

@eskenazit Done!

@eskenazit eskenazit force-pushed the feat/mcp-mock-mode branch from ca71c51 to 3aac49e Compare April 7, 2026 16:14
@eskenazit eskenazit mentioned this pull request Apr 7, 2026
4 tasks
- name: message
type: string
const: "Hello, World!"
const: "Hello, John Doe!"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actually, since we declare a inputParameter, I was thinking something more like :

value: "Hello, {{name}}!"

jlouvel added 7 commits April 8, 2026 17:31
MCP tools can now return static responses from const values in
outputParameters without requiring a consumes block or call/steps.

- Add third anyOf branch to McpTool schema for mock mode
- Extract MockResponseBuilder shared by REST and MCP adapters
- Add mock mode check in ToolHandler.handleToolCall()
- Add unit, integration tests and mock-mcp.yml example
- Specification-Schema: add mock mode to McpTool (third mode)
- FAQ: add Q&A for MCP mock tools with const values
- Roadmap: mark MCP mock feature as completed
- Guide-Use-Cases: add MCP no-adapter line item
- wrap-api-as-mcp: add mock mode to core concept and constraints
- design-guidelines: add MCP mock mode guidance
MappedOutputParameter uses unevaluatedProperties:false and does not
allow 'name'. Add a dedicated MockOutputParameter definition with
name, type, and const (all required) for mock mode tools.

- Add MockOutputParameter to naftiko-schema.json
- Reference it in McpTool mock anyOf branch
- Document MockOutputParameter in Specification-Schema.md
- Specification-Schema: add mock mode to McpTool (third mode)
- FAQ: add Q&A for MCP mock tools with const values
- Roadmap: mark MCP mock feature as completed
- Guide-Use-Cases: add MCP no-adapter line item
- wrap-api-as-mcp: add mock mode to core concept and constraints
- design-guidelines: add MCP mock mode guidance
MappedOutputParameter uses unevaluatedProperties:false and does not
allow 'name'. Add a dedicated MockOutputParameter definition with
name, type, and const (all required) for mock mode tools.

- Add MockOutputParameter to naftiko-schema.json
- Reference it in McpTool mock anyOf branch
- Document MockOutputParameter in Specification-Schema.md
@jlouvel jlouvel force-pushed the feat/mcp-mock-mode branch from 46b0de8 to 2bfa3d7 Compare April 8, 2026 21:42
@jlouvel
Copy link
Copy Markdown
Contributor Author

jlouvel commented Apr 9, 2026

@eskenazit Closing this one to start from scratch but a better approach #287

@jlouvel jlouvel closed this Apr 9, 2026
@eskenazit eskenazit deleted the feat/mcp-mock-mode branch April 10, 2026 15:44
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.

Framework : Add mocking feature to MCP server adapter similar to REST server adapter

2 participants