-
Notifications
You must be signed in to change notification settings - Fork 349
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
Adding cody mcp #6589
base: main
Are you sure you want to change the base?
Adding cody mcp #6589
Conversation
05f7fc9
to
e0bc155
Compare
730d2b8
to
21dfc17
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just noticed you are on an old branch so probably unaware of the changes we have on main where we automatically build the tool from openCtx providers via setupOpenCtxProviderListener
. In that method we can get the mentions from the MCP and convert them using openCtxProviderMetadata so that we can create the tools for all openCtx providers using the same createOpenCtxTools method.
Let me know if this is confusing or if you have any concerns about this approach!
vscode/src/chat/agentic/CodyTool.ts
Outdated
public parse(): string[] { | ||
try { | ||
JSON.parse(this.unprocessedText) | ||
} catch { | ||
return [] | ||
} | ||
const unparsedText = this.unprocessedText | ||
this.reset() | ||
return [unparsedText] | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public parse(): string[] { | |
try { | |
JSON.parse(this.unprocessedText) | |
} catch { | |
return [] | |
} | |
const unparsedText = this.unprocessedText | |
this.reset() | |
return [unparsedText] | |
} |
As discussed, this is for parsing the sub XML tag where the queries are returned by the LLM through stream. we can move this into execute instead
21dfc17
to
dbd67b1
Compare
…ovider (#6650) - Asynchronously create OpenCtxTools for model context protocol providers - Implement `createModelContextConfig` to handle the specific configuration for model context protocol providers - ## Test plan <!-- Required. See https://docs-legacy.sourcegraph.com/dev/background-information/testing_principles. --> Needs to test it with the changes in #6589 --------- Co-authored-by: arafatkatze <[email protected]>
0494a03
to
b408de1
Compare
b408de1
to
0113b3e
Compare
|
@@ -185,6 +187,33 @@ export function getOpenCtxProviders( | |||
providerUri: CODE_SEARCH_PROVIDER_URI, | |||
}) | |||
} | |||
const isMcpEnabled = vscode.workspace |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be done in getViewerSettingsProviders
below
@@ -0,0 +1,39 @@ | |||
import proxy from '@openctx/provider-modelcontextprotocoltools' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: it would be cool if we can get the mcpProviders in one call, instead needing to call the proxy and generate the providers on the client side
@@ -1242,7 +1242,29 @@ | |||
"openctx.providers": { | |||
"type": "object", | |||
"markdownDescription": "OpenCtx providers configuration.", | |||
"default": {} | |||
"default": {}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"default": {}, |
Do we need an empty default?
}, | ||
"toolNameQuery": { | ||
"type": "string", | ||
"markdownDescription": "Regex for the MCP provider tools in OpenCtx.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"markdownDescription": "Regex for the MCP provider tools in OpenCtx.", | |
"markdownDescription": "Regex for the MCP provider tools in OpenCtx.", | |
"example": "?" |
Would be cool if we can provide an example on how this should be used
const mcpResults = await openCtxClient.items( | ||
{ | ||
mention: { | ||
uri: '', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uri: '', | |
uri: '', |
We need to create a uri or the context item name will be empty showing in the context list
if (defaultConfig) { | ||
return defaultConfig[1] | ||
} | ||
return { | ||
title: provider.title, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (defaultConfig) { | |
return defaultConfig[1] | |
} | |
return { | |
title: provider.title, | |
return ( | |
defaultConfig?.[1] ?? { | |
title: provider.title, |
Co-authored-by: Beatrix <[email protected]>
Related OpenContext PR
Purposely waiting to do the final steps of the PR AFTER the base merge conflicts from Bee's PR is resolved and a demo is shared and discussed properly.
Test plan
Example MCP server implementation
https://www.loom.com/share/6c605cb1ccd4479ea269743ae6dd3529
cd src/everything/
npm run build
pnpm openctx:link
to be able to link the local OpenCTX latest reponode dist/test_mcp.js
If this works fine for you that means the local MCP is runningNow run the branch in the debugger and set the settings in vscode as
Please make sure to have three slashes
///
in the uri after file.For this example the toolnamequery is echo.
cd src/postgres/
npm run build
pnpm openctx:link
to be able to link the local OpenCTX latest repoNow run the branch in the debugger and set the settings in vscode as
Please make sure to have three slashes
///
in the uri after file.For this example the toolnamequery is query(that's defined in the MCP)
Now in deep cody ask the question:
from the local run of the postgres tool tell me the name of the users from the users table
NOTE: You gotta run the MCP with docker locally and make sure that postgres works properly for you before you do this.
For me I had
https://www.loom.com/share/a933fef57b6c42b5b5e06eced9e91c9f