Skip to content

Serve an L2M workflow as an MCP tool ​

What you get: A workflow that any MCP client can list and call as one tool, answer_from_kb, through L2M's MCP gateway.

Needs: No API key · Nodes: 5

An Expose as MCP Tool trigger turns the workflow into a tool named answer_from_kb, with one required argument, question. Inside, an agent with the echo model and the mock lookup_kb tool answers it. Put the workflow in a toolset on the MCP gateway and any MCP client holding a client token can list the tool and call it; each call runs the whole workflow. It runs with no API key. With echo, the answer is the question repeated back.

Steps ​

  1. Download workflow-as-mcp-tool-flow.json, or take it from the samples folder on GitHub.
  2. In the studio's workflow editor, import the file (see import and export).
  3. As an admin, open MCP → Toolsets in the sidebar, create a toolset and add the workflow. Its endpoint is /mcp/<slug> (we named ours kb-helper).
  4. Open MCP → Clients, create a client for that toolset (admin; you may be asked to confirm your identity again) and copy its token. It is shown once.
  5. Call the tool with curl (below), or paste the client's configuration snippet into your MCP client.

How it works ​

Diagram of the Workflow as MCP Tool workflowRuns Expose as MCP Tool, then Agent, then Output. Chat Model (echo) is attached to Agent as its chat model; MCP: lookup_kb is attached to Agent as its tool.Expose as MCP Tool (mcp_server_trigger)Expose as MCP Toolmcp_server_triggerAgent (agent_orchestrator)Agentagent_orchestratorChat Model (echo) (llm_call)Chat Model (echo)llm_callMCP: lookup_kb (mcp_tool)MCP: lookup_kbmcp_toolOutput (output)Outputoutput
Solid arrows are the order the steps run in. Dashed lines attach a chat model, memory, tools or workers to an agent; the agent uses them while it runs.
NodeTypeRole
Expose as MCP Toolmcp_server_triggerStep in the run
Agentagent_orchestratorStep in the run
OutputoutputStep in the run
Chat Model (echo)llm_callAttached to Agent on its chat_model port
MCP: lookup_kbmcp_toolAttached to Agent on its tool port

5 node types. Each type links to its config fields in the node reference.

Call it with curl ​

The gateway speaks MCP over Streamable HTTP. Put the client token in TOKEN (export TOKEN=l2m_mcp_...), then run these in order:

bash
# 1. Open a session and keep the Mcp-Session-Id header the server sends back.
SESSION=$(curl -si http://localhost:4000/mcp/kb-helper \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-11-25","capabilities":{},"clientInfo":{"name":"curl","version":"1"}}}' \
  | awk 'tolower($1)=="mcp-session-id:" {print $2}' | tr -d '\r')

# Tell the server the client is ready, as the MCP spec asks.
curl http://localhost:4000/mcp/kb-helper \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -H "Mcp-Session-Id: $SESSION" \
  -H "MCP-Protocol-Version: 2025-11-25" \
  -d '{"jsonrpc":"2.0","method":"notifications/initialized"}'

# 2. Call the tool in that session. (List them first with the same request and
#    "method":"tools/list", "params":{}.)
curl http://localhost:4000/mcp/kb-helper \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -H "Mcp-Session-Id: $SESSION" \
  -H "MCP-Protocol-Version: 2025-11-25" \
  -d '{"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"answer_from_kb","arguments":{"question":"What is MCP?"}}}'

# 3. End the session.
curl -X DELETE http://localhost:4000/mcp/kb-helper \
  -H "Authorization: Bearer $TOKEN" \
  -H "Mcp-Session-Id: $SESSION"

What came back on our install:

  • initialize: HTTP 200 with an mcp-session-id header and {"protocolVersion":"2025-11-25","capabilities":{"tools":{"listChanged":false}},"serverInfo":{"name":"l2m-kb-helper","title":"KB helper",...}}.
  • tools/list: one tool, answer_from_kb, with the description and input schema from the trigger.
  • tools/call: content with the workflow output as JSON text, the same object as structuredContent ({"result":"Echo: What is MCP?"}), and the run's id in _meta.executionId.
  • DELETE: 204 No Content.

Each call is a full run, listed in the execution history with the trigger type mcp_gateway. The gateway speaks MCP protocol versions 2025-11-25, 2025-06-18 and 2025-03-26. An MCP client library or app does these steps for you.

The sample's legacy routes are public ​

The trigger also has a path (kb-helper) and authMode: "public", which serve the older REST routes GET /api/mcp-server/kb-helper/manifest and POST /api/mcp-server/kb-helper/invoke. On our install both answered without any credentials, and invoke ran the workflow. They are not MCP, so MCP clients do not need them: set the trigger's auth mode to bearer with a stored secret, or remove the path, before you deploy. See Expose a workflow as an MCP tool.

Make it yours ​

  • Change toolName, toolDescription and inputSchema on the trigger. The description is what other agents' models read to decide when to call your tool, so make it specific.
  • Replace the agent's echo model with a real one, or replace the agent with a retrieval step and an LLM call, as in the RAG knowledge base recipe.
  • Call it from another L2M instance: register https://<l2m-host>/mcp/<slug> there with the http_mcp adapter and the client token as a stored secret.

Make it safer ​

These controls are optional; the recipe runs without them.

  • Give each client only the toolsets it needs, the lowest role that works, and an expiry.
  • Add tool policy rules scoped to the client or the toolset, including require-approval rules.
  • Cap each client with a budget scoped to MCP client and a rate limit on the client.

Further reading ​

This website (not the L2M product) uses Google Analytics, only after you accept cookies. Cookie settings