Skip to content

Commit 726dc6c

Browse files
authored
Merge branch 'master' into feat/span-first-2
2 parents 7947889 + 5d14405 commit 726dc6c

2 files changed

Lines changed: 36 additions & 52 deletions

File tree

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
token: ${{ steps.token.outputs.token }}
3232
fetch-depth: 0
3333
- name: Prepare release
34-
uses: getsentry/craft@fd370d4d54bec9ff07f909d88a3c4aec6f0ba22b # v2
34+
uses: getsentry/craft@beea4aba589c66381258cbd131c5551ae8245b82 # v2
3535
env:
3636
GITHUB_TOKEN: ${{ steps.token.outputs.token }}
3737
with:

tests/integrations/fastmcp/test_fastmcp.py

Lines changed: 35 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ async def __call__(self, *args, **kwargs):
4343
from mcp.server.sse import SseServerTransport
4444
from mcp.server.streamable_http_manager import StreamableHTTPSessionManager
4545

46+
try:
47+
from fastmcp.prompts import Message
48+
except ImportError:
49+
Message = None
50+
51+
4652
from starlette.responses import Response
4753
from starlette.routing import Mount, Route
4854
from starlette.applications import Starlette
@@ -611,15 +617,18 @@ async def test_fastmcp_prompt_sync(
611617
@mcp.prompt()
612618
def code_help_prompt(language: str):
613619
"""Get help for a programming language"""
614-
return [
615-
{
616-
"role": "user",
617-
"content": {
618-
"type": "text",
619-
"text": f"Tell me about {language}",
620-
},
621-
}
622-
]
620+
message = {
621+
"role": "user",
622+
"content": {
623+
"type": "text",
624+
"text": f"Tell me about {language}",
625+
},
626+
}
627+
628+
if FASTMCP_VERSION is not None and FASTMCP_VERSION.startswith("3"):
629+
message = Message(message)
630+
631+
return [message]
623632

624633
with start_transaction(name="fastmcp tx"):
625634
result = await stdio(
@@ -692,19 +701,24 @@ async def test_fastmcp_prompt_async(
692701
@mcp.prompt()
693702
async def async_prompt(topic: str):
694703
"""Get async prompt for a topic"""
695-
return [
696-
{
697-
"role": "user",
698-
"content": {"type": "text", "text": f"What is {topic}?"},
699-
},
700-
{
701-
"role": "assistant",
702-
"content": {
703-
"type": "text",
704-
"text": "Let me explain that",
705-
},
704+
message1 = {
705+
"role": "user",
706+
"content": {"type": "text", "text": f"What is {topic}?"},
707+
}
708+
709+
message2 = {
710+
"role": "assistant",
711+
"content": {
712+
"type": "text",
713+
"text": "Let me explain that",
706714
},
707-
]
715+
}
716+
717+
if FASTMCP_VERSION is not None and FASTMCP_VERSION.startswith("3"):
718+
message1 = Message(message1)
719+
message2 = Message(message2)
720+
721+
return [message1, message2]
708722

709723
_, result = json_rpc(
710724
app,
@@ -896,36 +910,6 @@ def test_tool(value: int) -> int:
896910
assert mcp_spans[0]["origin"] == "auto.ai.mcp"
897911

898912

899-
@pytest.mark.parametrize("FastMCP", fastmcp_implementations, ids=fastmcp_ids)
900-
def test_fastmcp_without_request_context(sentry_init, capture_events, FastMCP):
901-
"""Test FastMCP handling when no request context is available"""
902-
sentry_init(
903-
integrations=[MCPIntegration()],
904-
traces_sample_rate=1.0,
905-
)
906-
events = capture_events()
907-
908-
mcp = FastMCP("Test Server")
909-
910-
# Clear request context
911-
if request_ctx is not None:
912-
request_ctx.set(None)
913-
914-
@mcp.tool()
915-
def test_tool_no_ctx(x: int) -> dict:
916-
"""Test tool without context"""
917-
return {"result": x + 1}
918-
919-
with start_transaction(name="fastmcp tx"):
920-
result = call_tool_through_mcp(mcp, "test_tool_no_ctx", {"x": 99})
921-
922-
assert result == {"result": 100}
923-
924-
# Should still create transaction even if context is missing
925-
(tx,) = events
926-
assert tx["type"] == "transaction"
927-
928-
929913
# =============================================================================
930914
# Transport Detection Tests
931915
# =============================================================================

0 commit comments

Comments
 (0)