Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add: mcp support as client. #10833

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Add: mcp support as client. #10833

wants to merge 1 commit into from

Conversation

Fraggle
Copy link
Contributor

@Fraggle Fraggle commented Feb 17, 2025

Description

This draft PR does 2 things:

Add support for Dust as an MCP client via a new MCPAction

This allow for an agent to run tools exposed by MCP servers.

Add a rudimentary MCP relay server

This allow MCP servers running on localhost (eg: in a Front "app") to be exposed to the dust agent.

It works by exposing a websocket endpoint for the localhost MCP Servers to connect to and keep.
On the other side, it expose itself as an http sse MCPServer to from the standpoint of the Dust Agent MCPClient, it's fully transparent.

The relay itself and the custom communication layer over websocket are very rudimentary, on that stand point it's really a POC.

The first goal is just to enable localhost MCP actions use-cases (to avoid a lot of UI complexity needed by the other uses cases).

Tests

Locally

Risk

Low, behind a feature flag.

Deploy Plan

Deploy the relay in our infra. Deploy front

@Fraggle Fraggle requested review from spolu, fontanierh and flvndvd and removed request for spolu February 17, 2025 08:24
step: number;
}

const CONTEXT_SIZE_DIVISOR_FOR_OUTPUT = 2;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think divider

role: "function" as const,
name: "missing_function_call_name",
function_call_id: this.functionCallId ?? "missing_function_call_id",
content: `Error: the content was not tokenized`,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand this message

role: "function" as const,
name: this.functionCallName,
function_call_id: "missing_function_call_id",
content: `Error: the content was not tokenized`,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

role: "function" as const,
name: this.functionCallName,
function_call_id: this.functionCallId,
content: `Error: the content was not tokenized`,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this one I do understand :p

role: "function" as const,
name: this.functionCallName,
function_call_id: this.functionCallId,
content: `Error: Action output has too many tokens to be included.`,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we rather truncate (and append somnething like "[X more characters truncated]") ?

// the generation of the params. We store the action here as the params have been generated, if
// an error occurs later on, the error will be stored on the parent agent message.
const action = await AgentMCPAction.create({
host: "remote", // TODO(mcp): add the host of the MCP tool dynamically
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OOC can you provide a few more tokens regarding this comment ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm actually reworking this part, should be clearer (also, design doc incoming).

Copy link
Contributor

@fontanierh fontanierh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quite cool

// - system: the MCP tool is running inside the Dust system
// - isolated: the MCP tool is running inside a isolated environment (e.g. in a container)
// - remote: the MCP tool is running outside the Dust system (e.g. on another machine)
export type MCPHostType = "client" | "system" | "isolated" | "remote";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very cool

@@ -23,6 +24,9 @@ export type ConversationBaseActionType =
| "conversation_list_files_action"
| "conversation_include_file_action";

export type MCPBaseActionType = MCPActionType["type"];
// will also support "external" (run by an external server), "custom" (run by us in isolation) and "system" (dust provided actions)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

external -> remote and custom -> isolated ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, i iterated on naming quite a bit :)

@Fraggle Fraggle added the sdk-ack Used to acknowledge that you are not breaking the public API. label Feb 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sdk-ack Used to acknowledge that you are not breaking the public API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants