Workflow published as MCP do not report usage #21842

Closed
opened 2026-02-21 20:14:33 -05:00 by yindo · 1 comment
Owner

Originally created by @DavideDelbianco on GitHub (Jan 22, 2026).

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.11.4

Cloud or Self Hosted

Cloud

Steps to reproduce

Create a workflow that consumes tokens
Publish it as a tool
Publish it as MCP and add the MCP tool to your dify instance

use the tool in another workflow as the "workflow as tool"
repeat the process using it as "MCP tool"

reporting token usage in metadata is important for tracing tools like langfuse and for correct usage calculations when using tools in Agent node.

✔️ Expected Behavior

MCP tool should report usage just like Workflow as Tool

Image Image

Actual Behavior

the MCP tool does not include usage metadata

Originally created by @DavideDelbianco on GitHub (Jan 22, 2026). ### 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.11.4 ### Cloud or Self Hosted Cloud ### Steps to reproduce Create a workflow that consumes tokens Publish it as a tool Publish it as MCP and add the MCP tool to your dify instance use the tool in another workflow as the "workflow as tool" repeat the process using it as "MCP tool" reporting token usage in metadata is important for tracing tools like langfuse and for correct usage calculations when using tools in Agent node. ### ✔️ Expected Behavior MCP tool should report usage just like Workflow as Tool <img width="1412" height="396" alt="Image" src="https://github.com/user-attachments/assets/1233ec34-797d-42db-bf9f-d34b61362336" /> <img width="1492" height="536" alt="Image" src="https://github.com/user-attachments/assets/22b1b0a7-acd1-43ae-8d51-429753338f50" /> ### ❌ Actual Behavior the MCP tool does not include usage metadata
yindo added the 🐞 bug label 2026-02-21 20:14:33 -05:00
yindo closed this issue 2026-02-21 20:14:33 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Jan 22, 2026):

This is a confirmed bug: MCP tools in Dify do not report usage metadata (like token usage), while "Workflow as Tool" does. The root cause is that the MCPTool implementation does not extract or forward usage data from the MCP protocol’s _meta or meta fields, even though the protocol supports it. As a result, tools like Langfuse and Dify’s own usage tracking cannot see token or cost data for MCP tool invocations, which impacts tracing and cost monitoring for workflows using MCP tools see code analysis related issue.

There are no built-in workarounds or fixes for this in Dify 1.11.4. Some users have suggested manually aggregating usage data for other node types, but there’s no documented way to do this for MCP tools. The issue is tracked and recognized as important for accurate tracing and billing, especially with subflows and agent nodes discussion.

If you need usage tracking, consider using "Workflow as Tool" where possible until MCP tools support usage metadata reporting. For updates, watch the linked issues.

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other

Chat with Dosu Open in Cursor Join Discord Share on X

@dosubot[bot] commented on GitHub (Jan 22, 2026): <!-- Answer --> This is a confirmed bug: MCP tools in Dify do not report usage metadata (like token usage), while "Workflow as Tool" does. The root cause is that the MCPTool implementation does not extract or forward usage data from the MCP protocol’s `_meta` or `meta` fields, even though the protocol supports it. As a result, tools like Langfuse and Dify’s own usage tracking cannot see token or cost data for MCP tool invocations, which impacts tracing and cost monitoring for workflows using MCP tools [see code analysis](https://github.com/langgenius/dify/blob/515002a8ba7c62f6b614793994a529dc3d8a2ffc/api/core/tools/mcp_tool/tool.py#L28-L186) [related issue](https://github.com/langgenius/dify/issues/22970). There are no built-in workarounds or fixes for this in Dify 1.11.4. Some users have suggested manually aggregating usage data for other node types, but there’s no documented way to do this for MCP tools. The issue is tracked and recognized as important for accurate tracing and billing, especially with subflows and agent nodes [discussion](https://github.com/langgenius/dify/issues/23281). If you need usage tracking, consider using "Workflow as Tool" where possible until MCP tools support usage metadata reporting. For updates, watch the linked issues. <!-- 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/58582019-c493-464f-9721-e17dec3257b5?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/58582019-c493-464f-9721-e17dec3257b5?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/58582019-c493-464f-9721-e17dec3257b5?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/58582019-c493-464f-9721-e17dec3257b5?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/58582019-c493-464f-9721-e17dec3257b5?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/58582019-c493-464f-9721-e17dec3257b5?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/58582019-c493-464f-9721-e17dec3257b5?feedback_type=other)</sup> [![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/6088a4f4-073a-43f3-b3d4-4f06fb0c05a0/ask?utm_source=github)&nbsp;[![Open in Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=This%20is%20a%20confirmed%20bug%3A%20MCP%20tools%20in%20Dify%20do%20not%20report%20usage%20metadata%20%28like%20token%20usage%29%2C%20while%20%22Workflow%20as%20Tool%22%20does.%20The%20root%20cause%20is%20that%20the%20MCPTool%20implementation%20does%20not%20extract%20or%20forward%20usage%20data%20from%20the%20MCP%20protocol%E2%80%99s%20%60_meta%60%20or%20%60meta%60%20fields%2C%20even%20though%20the%20protocol%20supports%20it.%20As%20a%20result%2C%20tools%20like%20Langfuse%20and%20Dify%E2%80%99s%20own%20usage%20tracking%20cannot%20see%20token%20or%20cost%20data%20for%20MCP%20tool%20invocations%2C%20which%20impacts%20tracing%20and%20cost%20monitoring%20for%20workflows%20using%20MCP%20tools%C2%A0%5Bsee%20code%20analysis%5D%28https%3A//github.com/langgenius/dify/blob/515002a8ba7c62f6b614793994a529dc3d8a2ffc/api/core/tools/mcp_tool/tool.py%23L28-L186%29%C2%A0%5Brelated%20issue%5D%28https%3A//github.com/langgenius/dify/issues/22970%29.%0A%0AThere%20are%20no%20built-in%20workarounds%20or%20fixes%20for%20this%20in%20Dify%201.11.4.%20Some%20users%20have%20suggested%20manually%20aggregating%20usage%20data%20for%20other%20node%20types%2C%20but%20there%E2%80%99s%20no%20documented%20way%20to%20do%20this%20for%20MCP%20tools.%20The%20issue%20is%20tracked%20and%20recognized%20as%20important%20for%20accurate%20tracing%20and%20billing%2C%20especially%20with%20subflows%20and%20agent%20nodes%C2%A0%5Bdiscussion%5D%28https%3A//github.com/langgenius/dify/issues/23281%29.%0A%0AIf%20you%20need%20usage%20tracking%2C%20consider%20using%20%22Workflow%20as%20Tool%22%20where%20possible%20until%20MCP%20tools%20support%20usage%20metadata%20reporting.%20For%20updates%2C%20watch%20the%20linked%20issues.)&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/31402)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#21842