Skip to main content

Unit test tools directly

Tools are just functions. Test them without a server:

Tools using context

Tools that call get_context() require an active request. Test them via integration tests with a real server, or structure your tool to make the context-dependent part mockable:

Integration test with MCPClient

Test the full server:

Test registration

Verify tools register correctly:

Isolation

Since decorators don’t bind to servers at import time, each test gets clean state:
Last modified on June 30, 2026