https://promptfoo.dev/ logo
Hi I am trying to test my mcp server. I used two a...
# questions
s
1. providers: - id: openai:chat:gpt-4 config: mcp: enabled: true server: name: my-mcp-server url: '' it gives response as json like this ## [{"id":"call_X4129obXuAlKku02qOKFWk6d","type":"function","function":{"name":"namespaces_list","arguments":"{}"}}] instead of getting actual data. 2. providers: - id: openai:responses:gpt-4.1-2025-04-14 config: tools: - type: mcp server_label: my-mcp-server server_url: require_approval: never allowed_tools: ['namespaces_list'] max_output_tokens: 1500 temperature: 0.3 instructions: 'You are a helpful research assistant. Use the available MCP tools to search for accurate information about repositories and provide comprehensive answers.' i get this : API error: 424 Failed Dependency {"error":{"message":"Error retrieving tool list from MCP server: 'my-mcp-server'. Http status code: 424 (Failed Dependency)","type":"external_connector_error","param":"tools","code":"http_error"}} i am using latest version of promptfoo can anybody help
t
@[Promptfoo] Faizan pls?
u
Hey, what I'd recommend if you're trying to test the results, that you use a custom provider. We have a simple template for you to modify here: https://github.com/promptfoo/mcp-agent-provider/. There's instructions to just modify the config to allow you to specify your mcp server. Let me know how that goes or if you have any questions!
s
@[Promptfoo] Faizan i want to test a remote mcp server with headers taking some authentication value like x-api-key, Authorisation ... Thats why i had tried the above options, i saw the code base you have shared, does it allow remote mcp server? i cant see any documentation for the same.
May be i can explain what i am trying to achieve here. I have a mcp server that is hosted remotely which uses headers like Authorization, x-api-key for authentication purposes. I want to use models like gpt.. to ask any prompts like
list all pods running on namespace
. which should reach out to my remotely hosted mcp servers for the answers. attaching the files and the responses recieved as comments (in the file). https://cdn.discordapp.com/attachments/1408399858192093184/1409425292782604308/k8s-mcp.yaml?ex=68ad5517&is=68ac0397&hm=46eaa86e8c4c6c39d96d6e88e2ac151e346b2ccbc65bf03f08adca3e1c189ddc& https://cdn.discordapp.com/attachments/1408399858192093184/1409425293135052850/k8s-tools.yaml?ex=68ad5517&is=68ac0397&hm=9d1b6606b2f22940d9cc2dc7ba1b1ad5967a983179649af5dbfa239c6fde9d4e&
u
Hey @suraj_43399, the example I shared does support remote servers. Take a look at our docs here: https://www.promptfoo.dev/docs/integrations/mcp/. Just modify the promptfooconfig.yaml in that repo with your config and it should work
s
i tried @[Promptfoo] Faizan Evaluating [░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░] 0% | 0/1 | Failed to connect to MCP server: The "file" argument must be of type string. Received undefined Failed to connect to MCP server undefined: TypeError [ERR_INVALID_ARG_TYPE]: The "file" argument must be of type string. Received undefined at normalizeSpawnArguments (node:child_process:548:3) at Object.spawn (node:child_process:755:13) at spawn (/Users/surajprabakark/promptfoo/mcp-agent-provider/node_modules/cross-spawn/index.js:12:24) at /Users/surajprabakark/promptfoo/mcp-agent-provider/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/stdio.js:74:55 at new Promise () at StdioClientTransport.start (/Users/surajprabakark/promptfoo/mcp-agent-provider/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/stdio.js:72:16) at Client.connect (/Users/surajprabakark/promptfoo/mcp-agent-provider/node_modules/@modelcontextprotocol/sdk/dist/cjs/shared/protocol.js:99:31) at Client.connect (/Users/surajprabakark/promptfoo/mcp-agent-provider/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/index.js:65:21) at MCPClient.connect (/Users/surajprabakark/promptfoo/mcp-agent-provider/src/mcp-client.js:34:25) at OpenAIAgentProvider.initialize (/Users/surajprabakark/promptfoo/mcp-agent-provider/src/openai-agent-provider.js:32:22) { code: 'ERR_INVALID_ARG_TYPE' } Evaluating [████████████████████████████████████████] 100% | 1/1 | file://./src/openai-agent-provider.js "{{prompt}}" prompt=Get the remote server is not connected
Copy code
providers:
  - id: file://./src/openai-agent-provider.js
    config:
      apiBaseUrl: "https://api.openai.com/v1"
      mcpServers:
#        - command: "npx"
#          args: ["-y", "@promptfoo/evil-mcp-server@latest"]
        - url: '<remote-url>'
          name: my-mcp-server
          headers:
            x-api-key: '<x-api-key>'
the abpve is how i changed it
u
Hey @suraj_43399, thanks for letting me know- I think this repo was a bit outdated. I just pushed an update that should support your use case, please give it another try 🙂
s
@[Promptfoo] Faizan , thanks, it is working after the update. is this something under development ? how can we use it like other providers as in the documentation.
u
Hey @suraj_43399, promptfoo users typically end up using custom providers like this one when they have complex use cases, so moving forward with your testing with this provider is totally fine. I do have an idea of adding this as a simple provider in a future release though.
s
Thanks @[Promptfoo] Faizan
u
hey @suraj_43399 , the only thing I would change is that you should add the tools your mcp server has to the redteam.purpose
also recommend using our
mcp
plugin, as well as
prompt-injection
and
sql-injection
. Other plugins might be more applicable to your tools too, I would check out all the plugins https://www.promptfoo.dev/docs/red-team/plugins/
s
Thanks @[Promptfoo] Faizan , i will try them
2 Views