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 initial support for MCP #14598

Merged
merged 15 commits into from
Dec 13, 2024
Merged

Add initial support for MCP #14598

merged 15 commits into from
Dec 13, 2024

Conversation

JonasHelming
Copy link
Contributor

@JonasHelming JonasHelming commented Dec 8, 2024

fixed #14523

What it does

Adds initial support for Model Context Servers (see here)

How to test

Please check the readme. Be aware that the file MCP server has a bug about cases sensitivity, so if it does not work, tell the LLM the correct folder case sensitive.

Follow-ups

Currently, the interaction with MCP servers is manual, we should think about a better way to support users, e.g. to auto-start servers. For now, the integration allows users to "play around"

Breaking changes

  • This PR introduces breaking changes and requires careful review. If yes, the breaking changes section in the changelog has been updated.

Attribution

Review checklist

Reminder for reviewers

fixed #14523

Signed-off-by: Jonas Helming <jhelming@eclipsesource.com>
@JonasHelming
Copy link
Contributor Author

Copy link
Member

@sdirix sdirix left a comment

Choose a reason for hiding this comment

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

I tested with the filesystem server. In general the functionality works for me 👍

I added some comments. Next I will take a look at the type issue.

packages/ai-mcp/src/node/mcp-server.ts Outdated Show resolved Hide resolved
packages/ai-mcp/src/node/mcp-server.ts Outdated Show resolved Hide resolved
packages/ai-mcp/src/node/mcp-server.ts Outdated Show resolved Hide resolved
packages/ai-mcp/src/node/mcp-server.ts Outdated Show resolved Hide resolved
packages/ai-mcp/src/node/mcp-server.ts Outdated Show resolved Hide resolved
packages/ai-mcp/src/node/mcp-server-manager-impl.ts Outdated Show resolved Hide resolved
packages/ai-mcp/src/node/mcp-server-manager-impl.ts Outdated Show resolved Hide resolved
packages/ai-mcp/src/node/mcp-server-manager-impl.ts Outdated Show resolved Hide resolved
packages/ai-mcp/src/node/mcp-server-manager-impl.ts Outdated Show resolved Hide resolved
packages/ai-mcp/src/node/mcp-server-manager-impl.ts Outdated Show resolved Hide resolved
JonasHelming and others added 7 commits December 11, 2024 19:49
Co-authored-by: Stefan Dirix <sdirix@eclipsesource.com>
Co-authored-by: Stefan Dirix <sdirix@eclipsesource.com>
Co-authored-by: Stefan Dirix <sdirix@eclipsesource.com>
Co-authored-by: Stefan Dirix <sdirix@eclipsesource.com>
Co-authored-by: Stefan Dirix <sdirix@eclipsesource.com>
Co-authored-by: Stefan Dirix <sdirix@eclipsesource.com>
Signed-off-by: Jonas Helming <jhelming@eclipsesource.com>
@JonasHelming JonasHelming requested a review from sdirix December 12, 2024 08:11
Copy link
Member

@sdirix sdirix left a comment

Choose a reason for hiding this comment

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

Works much better. I have some more minor comments

packages/ai-mcp/README.md Outdated Show resolved Hide resolved
packages/ai-mcp/README.md Outdated Show resolved Hide resolved
packages/ai-mcp/README.md Outdated Show resolved Hide resolved
packages/ai-core/src/common/tool-invocation-registry.ts Outdated Show resolved Hide resolved
packages/ai-mcp/README.md Outdated Show resolved Hide resolved
packages/ai-mcp/src/browser/mcp-command-contribution.ts Outdated Show resolved Hide resolved
packages/ai-mcp/src/browser/mcp-command-contribution.ts Outdated Show resolved Hide resolved
packages/ai-mcp/src/browser/mcp-command-contribution.ts Outdated Show resolved Hide resolved
Copy link
Member

@sdirix sdirix left a comment

Choose a reason for hiding this comment

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

LGTM. @JonasHelming please double check once before we merge to make sure I did not introduce any regressions

@JonasHelming
Copy link
Contributor Author

Two new issues:

  • Argments do not work anymore
  • already started servers are not filtered
    I will have a look

1. properties for valid functions are rejected
2. Started servers are not filtered

Signed-off-by: Jonas Helming <jhelming@eclipsesource.com>
@JonasHelming
Copy link
Contributor Author

@sdirix I fixed the two remaining bugs I found, fine with merging?

Copy link
Member

@sdirix sdirix left a comment

Choose a reason for hiding this comment

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

Thanks for the fixes. I have some minor change suggestions. I will commit them shortly myself.

Comment on lines 58 to 59
// eslint-disable-next-line @typescript-eslint/no-explicit-any
typeof (value as any).type === 'string' &&
Copy link
Member

Choose a reason for hiding this comment

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

This can be simplified

Suggested change
// eslint-disable-next-line @typescript-eslint/no-explicit-any
typeof (value as any).type === 'string' &&
typeof value.type === 'string' &&

Since a few versions Typescript is smart enough to allow access to fields when they were checked via the in parameter before. If your IDE complains here then you are somehow not consuming the Typescript version of the repo.

for (const [name, description] of updatedServers) {
const oldDescription = oldServers.get(name);
// We know that that the descriptions are actual JSONObjects as we construct them ourselves
if (!oldDescription || !PreferenceProvider.deepEqual(oldDescription as unknown as JSONObject, description as unknown as JSONObject)) {
Copy link
Member

Choose a reason for hiding this comment

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

During testing I noticed a case in which the deepEqual fails, i.e. when deleting the whole env object in the preference. Not sure why this happens, seems to be an error in the 3rd party library we call. Therefore let's surround this with try/catch here and assume a difference.
I will open a follow up ticket so we can resolve this at a later point in a cleaner fashion.

Copy link
Member

@sdirix sdirix left a comment

Choose a reason for hiding this comment

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

Works for me. Thanks for the great work!

@JonasHelming JonasHelming merged commit 901c932 into master Dec 13, 2024
11 checks passed
@github-actions github-actions bot added this to the 1.57.0 milestone Dec 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

[Theia AI] Add Support for Model Context Protocol (MCP)
2 participants