Skip to main content
Glama
taiki-yoshida

copilot-studio-code

copilot-studio-code

一个本地 MCP 服务器,为 Microsoft Copilot Studio 智能体提供类似 Claude-Code 的工具,用于操作本地文件系统和 Shell——你可以直接从 Copilot Studio 测试画布中读取、编辑、搜索文件并运行命令。附带一个可导入的 Copilot Studio 解决方案,让你能在几分钟内搭建起一个可用的智能体。

公开的工具

工具

用途

read_file

读取 UTF-8 文本文件。

write_file

创建或覆盖文件。

edit_file

精确匹配字符串替换(需要唯一匹配,或设置 replace_all=true)。

list_dir

列出目录中的条目。

glob

查找符合 glob 模式的文件。

grep

在文件中进行正则表达式搜索(跳过 node_modules.gitdist)。

run_shell

执行 Shell 命令(Windows 上为 PowerShell,其他系统为 bash)。在 strict 模式下禁用。

安全模式(启动时选择)

模式

路径限制

run_shell

strict

强制执行

禁用

moderate (默认)

强制执行

启用,审计日志记录

open

关闭

启用,审计日志记录

模式选择优先级如下:

  1. SAFETY 环境变量 (strict / moderate / open)

  2. --safety <mode> 命令行标志

  3. 启动时的交互式提示(10秒超时 → moderate

所有 write_fileedit_filerun_shell 的调用都会被追加到 <root>/.copilotstudio-mcp/audit.log 中。

运行

npm install
npm start

服务器会打印类似以下内容:

copilot-studio-code MCP server
  workspace root : E:\Dev\projects\my-project
  safety mode    : moderate
  listening on   : http://localhost:8787/mcp
  health check   : http://localhost:8787/healthz

覆盖它所操作的工作区:

$env:WORKSPACE_ROOT = "E:\Dev\some-other-project"; npm start

连接到 Copilot Studio

Copilot Studio 是云托管的,因此无法访问 localhost。请使用 Microsoft Dev Tunnels 通过 HTTPS 暴露该服务器。

1. 安装并登录 dev tunnels

winget install Microsoft.devtunnel
devtunnel user login

2. 为 8787 端口创建持久隧道

devtunnel create copilotstudio-mcp --allow-anonymous
devtunnel port create copilotstudio-mcp -p 8787 --protocol http
devtunnel host copilotstudio-mcp

devtunnel host 会打印一个公共 URL,例如 https://<id>-8787.usw2.devtunnels.ms。保持其运行状态。

去掉 --allow-anonymous,隧道将要求在 Copilot Studio 端使用 MS 账户进行身份验证。建议在调试成功后使用此方式。

3. 将 MCP 服务器连接到 Copilot Studio 智能体

有两种方式:导入预构建的解决方案(最快),或手动配置智能体。

方案 A — 导入预构建的解决方案

solution/ 文件夹中提供了一个未托管的 Copilot Studio 解决方案,其中包含一个预配置的智能体(开启生成式编排,内容审核级别为低)、一个用于 MCP 服务器的自定义连接器,以及一个将工具呈现给规划器的 WorkspaceMCP 主题。

  1. 打开 https://make.powerapps.com → 你的环境 → 解决方案 (Solutions)导入解决方案 (Import solution)

  2. 上传 solution/CopilotStudioCode_1_0_0_0.zip。按照向导使用默认设置即可。

  3. 导入后,打开 Workspace MCP 自定义连接器 → 编辑 (Edit) → 在 常规 (General) 选项卡上,将占位符主机 YOUR-TUNNEL-ID-PORT.YOUR-REGION.devtunnels.ms 替换为你的真实 dev tunnel 主机(例如 abc123-8787.usw2.devtunnels.ms)。保存 → 更新连接器 (Update connector)

  4. 打开导入的智能体并跳转到第 4 步(测试画布)。

该解决方案不包含 MCP 服务器本身——它需要从本仓库在本地运行。连接器只是指向它。

方案 B — 手动配置智能体

  1. 打开 Copilot Studio → 你的智能体 → 工具 (Tools)+ 添加工具 (+ Add a tool)Model Context Protocol

  2. 服务器 URL: https://<your-tunnel-id>-8787.usw2.devtunnels.ms/mcp

  3. 身份验证: 无 (None)(用于匿名隧道)或 Microsoft Entra(用于已验证的隧道)。

  4. 保存。Copilot Studio 会从 /mcp 获取工具列表并显示这七个工具。确保每个工具都在智能体上启用。

  5. 设置 → 生成式 AI (Generative AI) → 编排: 生成式 (Generative);内容审核: 低 (Low)。如果没有生成式编排,规划器将不会调度 MCP 工具。

4. 在测试画布中进行测试

打开测试画布并尝试以下提示:

  • "List the files in the workspace root."

  • "Read package.json and tell me what scripts are defined."

  • "Add a new script called lint that runs tsc --noEmit."

  • "Run git status and summarize the result."

智能体根据 src/tools.ts 中的描述按名称选择工具——如果智能体选择了错误的工具,请优化这些描述。

项目布局

src/                                  the MCP server (TypeScript)
  index.ts                            entry: safety prompt + boot
  server.ts                           express + Streamable HTTP MCP transport
  tools.ts                            the seven tool registrations
  safety.ts                           mode definitions
  paths.ts                            workspace-root path jail
  audit.ts                            JSONL audit log
solution/                             importable Copilot Studio solution
  CopilotStudioCode_1_0_0_0.zip       agent + connector + topics (unmanaged)
A
license - permissive license
-
quality - not tested
C
maintenance

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/taiki-yoshida/copilot-studio-code'

If you have feedback or need assistance with the MCP directory API, please join our Discord server