1b74b06753
Cut comment and docstring volume roughly in half across src, tests, examples, and docs_src: removed comments that restate the adjacent code, leftover development narration, section banners, and self-evident Args/Returns blocks, and compressed the remaining docstrings to a Google-style summary line plus only the detail that earns its place. Kept (and tightened) the load-bearing content: Raises sections, deprecation and version-availability notes, spec/RFC/issue references, why-comments for non-obvious decisions, and all coverage pragmas. The generated mcp_types.v* wire modules are untouched.
38 lines
1.2 KiB
Python
38 lines
1.2 KiB
Python
"""Completion behaviour against MCPServer, driven through the public Client API."""
|
|
|
|
import pytest
|
|
from mcp_types import (
|
|
Completion,
|
|
CompletionArgument,
|
|
CompletionContext,
|
|
CompletionsCapability,
|
|
PromptReference,
|
|
ResourceTemplateReference,
|
|
)
|
|
|
|
from mcp.server.mcpserver import MCPServer
|
|
from tests.interaction._connect import Connect
|
|
from tests.interaction._requirements import requirement
|
|
|
|
pytestmark = pytest.mark.anyio
|
|
|
|
|
|
@requirement("mcpserver:completion:capability-auto")
|
|
async def test_completion_capability_is_advertised_only_when_a_handler_is_registered(connect: Connect) -> None:
|
|
with_handler = MCPServer("completer")
|
|
|
|
@with_handler.completion()
|
|
async def complete(
|
|
ref: PromptReference | ResourceTemplateReference,
|
|
argument: CompletionArgument,
|
|
context: CompletionContext | None,
|
|
) -> Completion | None:
|
|
"""Registered only so the completions capability is advertised; never called."""
|
|
raise NotImplementedError
|
|
|
|
async with connect(with_handler) as client:
|
|
assert client.server_capabilities.completions == CompletionsCapability()
|
|
|
|
async with connect(MCPServer("plain")) as client:
|
|
assert client.server_capabilities.completions is None
|