https://promptfoo.dev/ logo
MCP server failed to fetch listtools.. using promp...
# ❓|questions
s
Hello! I have developed local MCP server using FastMCP. I want to check the tool_used and the tool_call is made or not.. MCP sever logic: from mcp.server import FastMCP mcp = FastMCP(name="my-mcp-server") @mcp.tool() def add_numbers(a: int, b: int) -> int: """Add two numbers.""" return a + b @mcp.tool() def create_page(page_name: str) -> str: """Create a new page.""" return f"Successfully created page: {page_name}" @mcp.tool() def rename_page(old_name: str, new_name: str) -> str: """Rename a page.""" return f"Successfully renamed page from {old_name} to {new_name}" def main(): mcp.settings.host = "0.0.0.0" mcp.settings.port = 8090 mcp.settings.debug = True mcp.run(transport="sse") # or transport="http" for HTTP if __name__ == "__main__": main() Promptfoo typescript test script is attached in file I'm getting below error when trying to debug locally.. 'TypeError: fetch failed\n at node:internal/deps/undici/undici:15422:13\n at SSEClientTransport.send (/Users/saraswathir_500054/Projects/promptfoo-src/promptfoo/node_modules/@modelcontextprotocol/sdk/src/client/sse.ts:249:18)\n at Client.notification (/Users/saraswathir_500054/Projects/promptfoo-src/promptfoo/node_modules/@modelcontextprotocol/sdk/src/shared/protocol.ts:640:5)\n at Client.connect (/Users/saraswathir_500054/Projects/promptfoo-src/promptfoo/node_modules/@modelcontextprotocol/sdk/src/client/index.ts:175:7)\n at MCPClient.connectToServer (/Users/saraswathir_500054/Projects/promptfoo-src/promptfoo/src/providers/mcp/client.ts💯11)\n at MCPClient.initialize (/Users/saraswathir_500054/Projects/promptfoo-src/promptfoo/src/providers/mcp/client.ts:38:7)\n at OpenAiChatCompletionProvider.initializeMCP (/Users/saraswathir_500054/Projects/promptfoo-src/promptfoo/src/providers/openai/chat.ts:48:5)' https://cdn.discordapp.com/attachments/1397901947171770458/1397901947289341952/mcp-tools.ts?ex=688aa963&is=688957e3&hm=c0dcbf59bb078739f169a8971745e005b3da15c436d7f566095ad097ee8c7f7e&
u
Hey @saraswathirekhala_44593 , I was able to get it working. I think you had a slight typo in your mcp server script, here's a corrected one, including instructions on how to run it: https://gist.github.com/faizanminhas/62d16fc4a100914486fe6ee7768f68bd. As long as you have that running in another terminal tab/window, it should work. Also, I would note that if you're running into issues loading an MCP server into promptfoo, try testing it with
npx @modelcontextprotocol/inspector
, and making sure that you can list tools using the mcp inspector- if not, then the issue is probably with your mcp server.
13 Views