Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/honeymcp/core/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
mark_attacker_detected,
resolve_session_id,
)
from honeymcp.storage.session_backend import SessionBackend
from honeymcp.storage.memory_backend import InMemorySessionBackend
from honeymcp.storage.redis_backend import RedisSessionBackend
from honeymcp.storage.sqlite_backend import SQLiteSessionBackend
Expand Down
48 changes: 48 additions & 0 deletions tests/test_fastmcp_integration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
"""Real FastMCP integration tests for HoneyMCP wrapping."""

import pytest

from fastmcp import FastMCP

from honeymcp import honeypot


def _first_text(result) -> str:
"""Extract text from FastMCP ToolResult-style responses."""
content = getattr(result, "content", result)
if isinstance(content, list) and content:
return getattr(content[0], "text", str(content[0]))
return str(content)


@pytest.mark.asyncio
async def test_wrapped_fastmcp_server_calls_regular_and_ghost_tools(tmp_path):
server = FastMCP("HoneyMCP integration")

@server.tool()
def add(a: int, b: int) -> int:
"""Add two numbers."""
return a + b

server = honeypot(
server,
ghost_tools=["list_cloud_secrets"],
use_dynamic_tools=False,
event_storage_path=tmp_path,
enable_dashboard=False,
)

tools = await server.list_tools()
tool_names = {tool.name for tool in tools}

assert "add" in tool_names
assert "list_cloud_secrets" in tool_names

regular_result = await server.call_tool("add", {"a": 2, "b": 3})
assert _first_text(regular_result) == "5"

ghost_result = await server.call_tool("list_cloud_secrets", {})
ghost_text = _first_text(ghost_result)

assert "AWS_ACCESS_KEY_ID" in ghost_text
assert list(tmp_path.glob("*/*.json"))
Loading