|
13 | 13 | # limitations under the License.
|
14 | 14 |
|
15 | 15 | import pytest
|
| 16 | + |
16 | 17 | from fastmcp.client import Client
|
17 | 18 | from fastmcp.client.transports import FastMCPTransport
|
18 | 19 | from fastmcp.server.server import FastMCP
|
19 | 20 | from mcp.server.fastmcp.tools import ToolManager
|
20 | 21 |
|
| 22 | +from testing_support.fixtures import function_not_called |
| 23 | +from testing_support.ml_testing_utils import disabled_ai_monitoring_settings |
| 24 | +from testing_support.validators.validate_transaction_metrics import validate_transaction_metrics |
| 25 | + |
| 26 | + |
21 | 27 | from testing_support.validators.validate_transaction_metrics import validate_transaction_metrics
|
22 | 28 | from newrelic.api.background_task import background_task
|
23 | 29 |
|
@@ -61,7 +67,6 @@ async def _test():
|
61 | 67 | async with Client(transport=FastMCPTransport(fastmcp_server)) as client:
|
62 | 68 | # Call the MCP tool, so we can validate the trace naming is correct.
|
63 | 69 | result = await client.call_tool("add_exclamation", {"phrase": "Python is awesome"})
|
64 |
| - |
65 | 70 | content = str(result.content[0])
|
66 | 71 | assert "Python is awesome!" in content
|
67 | 72 |
|
@@ -135,3 +140,38 @@ async def _test():
|
135 | 140 | assert "Python is cool" in content
|
136 | 141 |
|
137 | 142 | loop.run_until_complete(_test())
|
| 143 | + |
| 144 | + |
| 145 | +@disabled_ai_monitoring_settings |
| 146 | +@function_not_called("newrelic.api.function_trace", "FunctionTrace.__enter__") |
| 147 | +@background_task() |
| 148 | +def test_tool_tracing_aim_disabled(loop, fastmcp_server): |
| 149 | + async def _test(): |
| 150 | + async with Client(transport=FastMCPTransport(fastmcp_server)) as client: |
| 151 | + # Call the MCP tool, so we can validate the trace naming is correct. |
| 152 | + result = await client.call_tool("add_exclamation", {"phrase": "Python is awesome"}) |
| 153 | + content = str(result.content[0]) |
| 154 | + assert "Python is awesome!" in content |
| 155 | + |
| 156 | + loop.run_until_complete(_test()) |
| 157 | + |
| 158 | + |
| 159 | +@disabled_ai_monitoring_settings |
| 160 | +@function_not_called("newrelic.api.function_trace", "FunctionTrace.__enter__") |
| 161 | +@background_task() |
| 162 | +def test_resource_tracing_aim_disabled(loop, fastmcp_server): |
| 163 | + run_read_resources(loop, fastmcp_server, "greeting://Python") |
| 164 | + |
| 165 | + |
| 166 | +@disabled_ai_monitoring_settings |
| 167 | +@function_not_called("newrelic.api.function_trace", "FunctionTrace.__enter__") |
| 168 | +@background_task() |
| 169 | +def test_prompt_tracing_aim_disabled(loop, fastmcp_server): |
| 170 | + async def _test(): |
| 171 | + async with Client(transport=FastMCPTransport(fastmcp_server)) as client: |
| 172 | + result = await client.get_prompt("echo_prompt", {"message": "Python is cool"}) |
| 173 | + |
| 174 | + content = str(result) |
| 175 | + assert "Python is cool" in content |
| 176 | + |
| 177 | + loop.run_until_complete(_test()) |
0 commit comments