60e0ffc959
Upgrade checks / Notify on failure (push) Has been cancelled
Upgrade checks / Close issue on success (push) Has been cancelled
Schema Crash Test / Real-world schema crash test (232K schemas) (push) Has been cancelled
Run static analysis / static_analysis (push) Has been cancelled
Tests / Tests: Python 3.10 on ubuntu-latest (push) Has been cancelled
Tests / Tests: Python 3.13 on ubuntu-latest (push) Has been cancelled
Tests / Tests: Python 3.10 on windows-latest (push) Has been cancelled
Tests / Tests with lowest-direct dependencies (push) Has been cancelled
Tests / MCP conformance tests (push) Has been cancelled
Tests / Integration tests (push) Has been cancelled
Tests / Package install smoke (push) Has been cancelled
Upgrade checks / Static analysis (push) Has been cancelled
Upgrade checks / Tests: Python 3.10 on ubuntu-latest (push) Has been cancelled
Upgrade checks / Tests: Python 3.13 on ubuntu-latest (push) Has been cancelled
Upgrade checks / Tests: Python 3.10 on windows-latest (push) Has been cancelled
Upgrade checks / Integration tests (push) Has been cancelled
Update MCPServerConfig Schema / update-config-schema (push) Has been cancelled
Update SDK Documentation / update-sdk-docs (push) Has been cancelled
57 lines
1.7 KiB
Python
57 lines
1.7 KiB
Python
"""Tests for the Approval provider."""
|
|
|
|
from fastmcp import FastMCP
|
|
from fastmcp.apps.approval import Approval
|
|
|
|
|
|
class TestApprovalProvider:
|
|
async def test_request_approval_returns_structured_content(self):
|
|
server = FastMCP("test", providers=[Approval()])
|
|
|
|
result = await server.call_tool(
|
|
"request_approval",
|
|
{"summary": "Delete 47 files"},
|
|
)
|
|
assert result.structured_content is not None
|
|
|
|
async def test_request_approval_with_details(self):
|
|
server = FastMCP("test", providers=[Approval()])
|
|
|
|
result = await server.call_tool(
|
|
"request_approval",
|
|
{"summary": "Deploy to prod", "details": "Version 3.2.0"},
|
|
)
|
|
assert result.structured_content is not None
|
|
|
|
async def test_tool_visible_to_model(self):
|
|
server = FastMCP("test", providers=[Approval()])
|
|
|
|
tools = await server.list_tools()
|
|
tool_names = [t.name for t in tools]
|
|
assert "request_approval" in tool_names
|
|
|
|
async def test_custom_name(self):
|
|
server = FastMCP("test", providers=[Approval(name="Gate")])
|
|
|
|
tools = await server.list_tools()
|
|
tool_names = [t.name for t in tools]
|
|
assert "request_approval" in tool_names
|
|
|
|
async def test_custom_button_text(self):
|
|
server = FastMCP(
|
|
"test",
|
|
providers=[
|
|
Approval(
|
|
approve_text="Ship it",
|
|
reject_text="Nope",
|
|
title="Deploy Gate",
|
|
)
|
|
],
|
|
)
|
|
|
|
result = await server.call_tool(
|
|
"request_approval",
|
|
{"summary": "Deploy v3.2"},
|
|
)
|
|
assert result.structured_content is not None
|