MCP tools in agent error PluginInvokeError #15756

Closed
opened 2026-02-21 19:23:11 -05:00 by yindo · 5 comments
Owner

Originally created by @DavideDelbianco on GitHub (Jul 29, 2025).

Self Checks

  • I have read the Contributing Guide and Language Policy.
  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report, otherwise it will be closed.
  • 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

1.7.1

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

Create a workflow "Test With Space"
Enable its MCP server and give the workflow server the name "test_with_space"

Add the MCP server to the tools of its own workspace
Create a Chatflow with an Agent node and add the MCP tool

✔️ Expected Behavior

The tool "invocation" name should be set in the MCP configuration, just like it is present in workflow as tool.
That "invocation name" should be used for fetched MCP tools.

Image Image

On a side note, if the MCP standards allows hyphens in addition to underscores, please update the workflow as tool naming convention to be on par with MCP

Image

Actual Behavior

It seems that the workflow friendly name is used and because it contains spaces it is considered invalid:

Run failed: Failed to transform agent message: PluginInvokeError: {"args":{},"error_type":"Exception","message":"read llm model failed: request failed: [models] Bad Request Error, Error code: 400 - {'error': {'message': "Invalid 'tools[6].function.name': string does not match pattern. Expected a string that matches the pattern '^[a-zA-Z0-9_-]+$'.", 'type': 'invalid_request_error', 'param': 'tools[6].function.name', 'code': 'invalid_value'}}"}
Image

Friendly name vs tool_name
Image

thought that maybe Workflow MCP tool used the value of the Friendly name instead of the tool name
Image

Normal plugin shows the tool name not the friendly one:
Image

Tried to alter the MCP server name without success:
Image

It turns out the name it has issues with, is the resolved name of the workflow, because it is considered the tool name
Image

Image Image

Correcting the workflow name makes it work fine again.
I suggest adding a "tool invocation name" in the MCP configuration, just like there's one in workflow as tool

Originally created by @DavideDelbianco on GitHub (Jul 29, 2025). ### Self Checks - [x] I have read the [Contributing Guide](https://github.com/langgenius/dify/blob/main/CONTRIBUTING.md) and [Language Policy](https://github.com/langgenius/dify/issues/1542). - [x] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [x] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [x] I confirm that I am using English to submit this report, otherwise it will be closed. - [x] 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :) - [x] Please do not modify this template :) and fill in all the required fields. ### Dify version 1.7.1 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce Create a workflow "Test With Space" Enable its MCP server and give the workflow server the name "test_with_space" Add the MCP server to the tools of its own workspace Create a Chatflow with an Agent node and add the MCP tool ### ✔️ Expected Behavior The tool "invocation" name should be set in the MCP configuration, just like it is present in workflow as tool. That "invocation name" should be used for fetched MCP tools. <img width="615" height="337" alt="Image" src="https://github.com/user-attachments/assets/d81a2517-4c63-4c47-bab9-a056971520e6" /> <img width="584" height="588" alt="Image" src="https://github.com/user-attachments/assets/bd134580-1d9d-4f78-8d8e-150ea5fb2b2f" /> On a side note, if the MCP standards allows hyphens in addition to underscores, please update the workflow as tool naming convention to be on par with MCP <img width="618" height="244" alt="Image" src="https://github.com/user-attachments/assets/3b4c064c-f420-4a66-9757-a531b747f62b" /> ### ❌ Actual Behavior It seems that the workflow friendly name is used and because it contains spaces it is considered invalid: ```js Run failed: Failed to transform agent message: PluginInvokeError: {"args":{},"error_type":"Exception","message":"read llm model failed: request failed: [models] Bad Request Error, Error code: 400 - {'error': {'message': "Invalid 'tools[6].function.name': string does not match pattern. Expected a string that matches the pattern '^[a-zA-Z0-9_-]+$'.", 'type': 'invalid_request_error', 'param': 'tools[6].function.name', 'code': 'invalid_value'}}"} ``` <img width="1058" height="153" alt="Image" src="https://github.com/user-attachments/assets/e445c40d-89b2-4711-8dc9-7b8685db17d5" /> Friendly name vs tool_name <img width="782" height="210" alt="Image" src="https://github.com/user-attachments/assets/d4d2ccab-3d86-4b74-b977-89bcd4fbb733" /> thought that maybe Workflow MCP tool used the value of the Friendly name instead of the tool name <img width="1414" height="529" alt="Image" src="https://github.com/user-attachments/assets/d7b4f948-6828-4705-b34c-2c17336cda96" /> Normal plugin shows the tool name not the friendly one: <img width="1417" height="415" alt="Image" src="https://github.com/user-attachments/assets/2ce612d9-b0bd-4ad0-b7cd-9a334fbeefae" /> Tried to alter the MCP server name without success: <img width="407" height="151" alt="Image" src="https://github.com/user-attachments/assets/6cd1c99f-72a3-4328-899f-a6ba5eafd32c" /> It turns out the name it has issues with, is the resolved name of the workflow, because it is considered the tool name <img width="865" height="264" alt="Image" src="https://github.com/user-attachments/assets/ef682afc-82b7-415e-9b8b-a477e968233c" /> <img width="1520" height="339" alt="Image" src="https://github.com/user-attachments/assets/b2a437ec-5ae2-448f-95a9-2e124c292a7b" /> <img width="1460" height="344" alt="Image" src="https://github.com/user-attachments/assets/889c4b10-e994-4172-bd0a-ee7bc2ae86b0" /> Correcting the workflow name makes it work fine again. I suggest adding a "tool invocation name" in the MCP configuration, just like there's one in workflow as tool
yindo added the 🐞 bugstale labels 2026-02-21 19:23:11 -05:00
yindo closed this issue 2026-02-21 19:23:11 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Jul 29, 2025):

The error happens because MCP tools currently use the workflow's friendly name (which can include spaces or special characters) as the internal tool/function name, but the backend requires tool names to match the pattern ^[a-zA-Z0-9_-]+$—letters, numbers, underscores, and hyphens only, no spaces or special characters. Normal plugins sanitize tool names to meet this requirement, but MCP tools do not, which leads to the PluginInvokeError you’re seeing when the name contains spaces or other invalid characters reference.

As a workaround, make sure your workflow names and MCP tool names only use allowed characters (letters, numbers, underscores, hyphens). Avoid spaces and special characters in any name that could become a tool/function name. There’s currently no built-in sanitization or config option to fix this automatically.

A code-level fix would be to sanitize MCP tool names at the point where they’re constructed, similar to how plugin tool names are handled. Until that’s implemented, using only valid characters in your workflow and MCP tool names will prevent this error. If you need help with a manual workaround or have a lot of existing workflows to fix, let me know!

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Chat with Dosu Join Discord Share on X

@dosubot[bot] commented on GitHub (Jul 29, 2025): <!-- Answer --> The error happens because MCP tools currently use the workflow's friendly name (which can include spaces or special characters) as the internal tool/function name, but the backend requires tool names to match the pattern `^[a-zA-Z0-9_-]+$`—letters, numbers, underscores, and hyphens only, no spaces or special characters. Normal plugins sanitize tool names to meet this requirement, but MCP tools do not, which leads to the PluginInvokeError you’re seeing when the name contains spaces or other invalid characters [reference](https://github.com/langgenius/dify/issues/22867). As a workaround, make sure your workflow names and MCP tool names only use allowed characters (letters, numbers, underscores, hyphens). Avoid spaces and special characters in any name that could become a tool/function name. There’s currently no built-in sanitization or config option to fix this automatically. A code-level fix would be to sanitize MCP tool names at the point where they’re constructed, similar to how plugin tool names are handled. Until that’s implemented, using only valid characters in your workflow and MCP tool names will prevent this error. If you need help with a manual workaround or have a lot of existing workflows to fix, let me know! <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/bccc65e6-0ff8-4bef-9e72-e8bee83032ee?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/bccc65e6-0ff8-4bef-9e72-e8bee83032ee?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/bccc65e6-0ff8-4bef-9e72-e8bee83032ee?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/bccc65e6-0ff8-4bef-9e72-e8bee83032ee?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/bccc65e6-0ff8-4bef-9e72-e8bee83032ee?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/bccc65e6-0ff8-4bef-9e72-e8bee83032ee?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/bccc65e6-0ff8-4bef-9e72-e8bee83032ee?feedback_type=other)</sup>&nbsp;&nbsp;[![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/6088a4f4-073a-43f3-b3d4-4f06fb0c05a0/ask?utm_source=github)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/langgenius/dify/issues/23134)
Author
Owner

@dlmu-lq commented on GitHub (Aug 28, 2025):

I have an idea: when the tool name does not meet the standard regex, modify the tool_name at runtime (because I've noticed that some other plugin tools also have non-compliant tool names). Does the official team agree with this approach? I can propose a feature for it. By the way, what are some good ways to standardize a non-standardized name?

@dlmu-lq commented on GitHub (Aug 28, 2025): I have an idea: when the tool name does not meet the standard regex, modify the tool_name at runtime (because I've noticed that some other plugin tools also have non-compliant tool names). Does the official team agree with this approach? I can propose a feature for it. By the way, what are some good ways to standardize a non-standardized name?
Author
Owner

@dosubot[bot] commented on GitHub (Sep 28, 2025):

Hi, @DavideDelbianco. I'm Dosu, and I'm helping the Dify team manage their backlog and am marking this issue as stale.

Issue Summary:

  • You reported that MCP tools cause a PluginInvokeError in version 1.7.1 when workflow friendly names contain spaces.
  • The backend requires tool names to follow a strict pattern without spaces, but MCP tools currently use the workflow friendly name without sanitization.
  • A temporary workaround is to avoid spaces or special characters in workflow names.
  • Another user proposed dynamically sanitizing tool names at runtime and offered to contribute a feature for this.
  • The issue remains unresolved and under consideration for a proper fix.

Next Steps:

  • Please let me know if this issue is still relevant with the latest version of Dify by commenting here.
  • If I don’t hear back within 15 days, I will automatically close this issue.

Thanks for your understanding and contribution!

@dosubot[bot] commented on GitHub (Sep 28, 2025): Hi, @DavideDelbianco. I'm [Dosu](https://dosu.dev), and I'm helping the Dify team manage their backlog and am marking this issue as stale. **Issue Summary:** - You reported that MCP tools cause a PluginInvokeError in version 1.7.1 when workflow friendly names contain spaces. - The backend requires tool names to follow a strict pattern without spaces, but MCP tools currently use the workflow friendly name without sanitization. - A temporary workaround is to avoid spaces or special characters in workflow names. - Another user proposed dynamically sanitizing tool names at runtime and offered to contribute a feature for this. - The issue remains unresolved and under consideration for a proper fix. **Next Steps:** - Please let me know if this issue is still relevant with the latest version of Dify by commenting here. - If I don’t hear back within 15 days, I will automatically close this issue. Thanks for your understanding and contribution!
Author
Owner

@DavideDelbianco commented on GitHub (Oct 8, 2025):

The MCP tools still need this fix to the name of the invoked tool, it should not rely on the name of the originating workflow...

@DavideDelbianco commented on GitHub (Oct 8, 2025): The MCP tools still need this fix to the name of the invoked tool, it should not rely on the name of the originating workflow...
Author
Owner

@dosubot[bot] commented on GitHub (Dec 27, 2025):

Hi, @DavideDelbianco. I'm Dosu, and I'm helping the Dify team manage their backlog and am marking this issue as stale.

Issue Summary:

  • You reported that in version 1.7.1 (self-hosted Docker), MCP tools cause a PluginInvokeError due to using the workflow's friendly name with spaces as the tool name.
  • This naming violates backend rules because MCP tools currently lack sanitization of tool names, unlike normal plugins.
  • A workaround suggested was to avoid spaces or special characters in tool names.
  • Another user proposed dynamically sanitizing tool names at runtime and offered to contribute a feature.
  • You emphasized the need for MCP tools to use the invocation name rather than the workflow friendly name to resolve this.

Next Steps:

  • Please let me know if this issue is still relevant with the latest version of Dify by commenting here to keep the discussion open.
  • Otherwise, this issue will be automatically closed in 15 days.

Thank you for your understanding and contribution!

@dosubot[bot] commented on GitHub (Dec 27, 2025): Hi, @DavideDelbianco. I'm [Dosu](https://dosu.dev), and I'm helping the Dify team manage their backlog and am marking this issue as stale. **Issue Summary:** - You reported that in version 1.7.1 (self-hosted Docker), MCP tools cause a PluginInvokeError due to using the workflow's friendly name with spaces as the tool name. - This naming violates backend rules because MCP tools currently lack sanitization of tool names, unlike normal plugins. - A workaround suggested was to avoid spaces or special characters in tool names. - Another user proposed dynamically sanitizing tool names at runtime and offered to contribute a feature. - You emphasized the need for MCP tools to use the invocation name rather than the workflow friendly name to resolve this. **Next Steps:** - Please let me know if this issue is still relevant with the latest version of Dify by commenting here to keep the discussion open. - Otherwise, this issue will be automatically closed in 15 days. Thank you for your understanding and contribution!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#15756