-
Notifications
You must be signed in to change notification settings - Fork 149
Open the sample file and the mcp.json in a split editor when creating self-hosted MCP projects #4946
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
Open the sample file and the mcp.json in a split editor when creating self-hosted MCP projects #4946
Changes from 1 commit
44800d1
13188c3
5856acf
311065b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,16 +38,27 @@ export class MCPDownloadSnippetsExecuteStep extends AzureWizardExecuteStepWithAc | |
| await this.downloadFilesRecursively(context, sampleFiles, context.projectPath); | ||
| } | ||
|
|
||
| private static readonly languageExtensions: Partial<Record<ProjectLanguage, string>> = { | ||
| [ProjectLanguage.TypeScript]: '.ts', | ||
| [ProjectLanguage.Python]: '.py', | ||
| [ProjectLanguage.CSharp]: '.cs', | ||
| }; | ||
|
|
||
| private async downloadFilesRecursively(context: MCPProjectWizardContext, items: GitHubFileMetadata[], basePath: string): Promise<void> { | ||
| const sourceExt = context.serverLanguage ? MCPDownloadSnippetsExecuteStep.languageExtensions[context.serverLanguage] : undefined; | ||
| // Download all files and directories at this level in parallel | ||
| await Promise.all(items.map(async (item) => { | ||
| if (item.type === 'file') { | ||
| await MCPDownloadSnippetsExecuteStep.downloadSingleFile({ | ||
| const destPath = await MCPDownloadSnippetsExecuteStep.downloadSingleFile({ | ||
| context, item, | ||
| destDirPath: basePath, | ||
| serverLanguage: context.serverLanguage, | ||
| projectName: path.basename(context.projectPath) | ||
| }); | ||
| // Track the first source file matching the server language as the sample tool file | ||
| if (!context.sampleToolFilePath && sourceExt && destPath.endsWith(sourceExt)) { | ||
| context.sampleToolFilePath = destPath; | ||
| } | ||
|
||
| } else if (item.type === 'dir') { | ||
| // Create directory | ||
| const dirPath: string = path.join(basePath, item.name); | ||
|
|
@@ -73,7 +84,7 @@ export class MCPDownloadSnippetsExecuteStep extends AzureWizardExecuteStepWithAc | |
| destDirPath: string, | ||
| projectName: string | ||
| serverLanguage?: ProjectLanguage, | ||
| }): Promise<void> { | ||
| }): Promise<string> { | ||
| const { context, item, destDirPath, serverLanguage, projectName } = options; | ||
| const fileUrl: string = item.download_url; | ||
| let destinationPath: string = path.join(destDirPath, item.name); | ||
|
|
@@ -92,5 +103,6 @@ export class MCPDownloadSnippetsExecuteStep extends AzureWizardExecuteStepWithAc | |
| } | ||
| } | ||
| await AzExtFsExtra.writeFile(destinationPath, fileContent ?? ''); | ||
| return destinationPath; | ||
| } | ||
| } | ||
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.
sampleToolFilePathis set inside aPromise.allover downloads. Because the downloads resolve in nondeterministic order, the "first" matching file picked here is effectively whichever finishes first (and can even be overwritten if multiple resolves hit before the flag is observed). Consider collecting candidate paths during the traversal and selecting deterministically after the parallel work completes (e.g., prefer known tool paths per language usingitem.path, or pick by stable sort order) rather than mutatingcontextfrom concurrent tasks.