duck.contrib.mcp.testserver¶
MCP protocol feature test server.
This module provides a complete test MCP server implementation for validating Duck’s MCP support, including:
Tool registration and execution
Tool authorization using scopes
Server-to-client notifications
Progress notifications
Client sampling requests
Client root discovery
User elicitation requests
Resource listing and reading
Resource templates
Prompt generation
MCP session handling
SSE streaming transport
The server is intended for development and protocol verification only.
It exposes /mcp as an MCP endpoint and can be connected to MCP clients
such as MCP Inspector for testing supported features.
… rubric:: Example
Connect an MCP client to:
http://localhost:<port>/mcp
Authentication testing: Authorization: Bearer admin-token
The admin_test tool requires the admin scope.
Module Contents¶
Classes¶
MCP test server covering the main protocol features. |
API¶
- class duck.contrib.mcp.testserver.TestMCPServer(*args, **kwargs)[source]¶
Bases:
duck.contrib.mcp.MCPViewMCP test server covering the main protocol features.
Initialization
Collect all @tool / @resource / @prompt decorated methods on this instance into lookup dicts.
- async admin_test(message: str) dict[source]¶
Test scoped authorization.
Requires the client/user to have the
adminscope.
- async authenticate()[source]¶
Test authentication provider.
In a real server this would validate a token/session.
- name¶
‘duck-mcp-test-server’
- sse¶
True
- async test_notification(message: str) str[source]¶
Test sending custom notifications to the client.
This verifies that the active SSE stream receives server push messages.
- version¶
‘1.0.0’