fastmcp/tests/server/test_server_safety.py
Bill Easton 757678bc7e
fix: reject self-mount to prevent infinite recursion (#3925)
* fix: server safety guards for self-mount, duplicate middleware, mount arg order

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* Remove duplicate middleware and mount arg order checks

These are runtime type checking, not bugs — a type checker catches them.
Keep only the self-mount guard which is a semantic check.

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-14 12:10:19 -04:00

10 lines
246 B
Python

import pytest
from fastmcp import FastMCP
class TestMountSafety:
def test_self_mount_raises(self):
mcp = FastMCP("test")
with pytest.raises(ValueError, match="Cannot mount a server onto itself"):
mcp.mount(mcp)