copilot-studio-code
copilot-studio-code
一个本地 MCP 服务器,为 Microsoft Copilot Studio 智能体提供类似 Claude-Code 的工具,用于操作本地文件系统和 Shell——你可以直接从 Copilot Studio 测试画布中读取、编辑、搜索文件并运行命令。附带一个可导入的 Copilot Studio 解决方案,让你能在几分钟内搭建起一个可用的智能体。
公开的工具
工具 | 用途 |
| 读取 UTF-8 文本文件。 |
| 创建或覆盖文件。 |
| 精确匹配字符串替换(需要唯一匹配,或设置 |
| 列出目录中的条目。 |
| 查找符合 glob 模式的文件。 |
| 在文件中进行正则表达式搜索(跳过 |
| 执行 Shell 命令(Windows 上为 PowerShell,其他系统为 bash)。在 |
Related MCP server: ai-distiller-mcp
安全模式(启动时选择)
模式 | 路径限制 |
|
| 强制执行 | 禁用 |
| 强制执行 | 启用,审计日志记录 |
| 关闭 | 启用,审计日志记录 |
模式选择优先级如下:
SAFETY环境变量 (strict/moderate/open)--safety <mode>命令行标志启动时的交互式提示(10秒超时 →
moderate)
所有 write_file、edit_file 和 run_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 login2. 为 8787 端口创建持久隧道
devtunnel create copilotstudio-mcp --allow-anonymous
devtunnel port create copilotstudio-mcp -p 8787 --protocol http
devtunnel host copilotstudio-mcpdevtunnel host 会打印一个公共 URL,例如 https://<id>-8787.usw2.devtunnels.ms。保持其运行状态。
去掉
--allow-anonymous,隧道将要求在 Copilot Studio 端使用 MS 账户进行身份验证。建议在调试成功后使用此方式。
3. 将 MCP 服务器连接到 Copilot Studio 智能体
有两种方式:导入预构建的解决方案(最快),或手动配置智能体。
方案 A — 导入预构建的解决方案
solution/ 文件夹中提供了一个未托管的 Copilot Studio 解决方案,其中包含一个预配置的智能体(开启生成式编排,内容审核级别为低)、一个用于 MCP 服务器的自定义连接器,以及一个将工具呈现给规划器的 WorkspaceMCP 主题。
打开 https://make.powerapps.com → 你的环境 → 解决方案 (Solutions) → 导入解决方案 (Import solution)。
上传
solution/CopilotStudioCode_1_0_0_0.zip。按照向导使用默认设置即可。导入后,打开 Workspace MCP 自定义连接器 → 编辑 (Edit) → 在 常规 (General) 选项卡上,将占位符主机
YOUR-TUNNEL-ID-PORT.YOUR-REGION.devtunnels.ms替换为你的真实 dev tunnel 主机(例如abc123-8787.usw2.devtunnels.ms)。保存 → 更新连接器 (Update connector)。打开导入的智能体并跳转到第 4 步(测试画布)。
该解决方案不包含 MCP 服务器本身——它需要从本仓库在本地运行。连接器只是指向它。
方案 B — 手动配置智能体
打开 Copilot Studio → 你的智能体 → 工具 (Tools) → + 添加工具 (+ Add a tool) → Model Context Protocol。
服务器 URL:
https://<your-tunnel-id>-8787.usw2.devtunnels.ms/mcp身份验证: 无 (None)(用于匿名隧道)或 Microsoft Entra(用于已验证的隧道)。
保存。Copilot Studio 会从
/mcp获取工具列表并显示这七个工具。确保每个工具都在智能体上启用。设置 → 生成式 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
lintthat runstsc --noEmit.""Run
git statusand 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)Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Use your Mac, Windows or Linux computer from ChatGPT, Claude or Codex: files, commands, documents.
Connect ChatGPT, Claude, Cursor or VS Code to your Windows PC: files, terminal, browser, apps.
Use your own Windows, Mac or Linux computer from ChatGPT, Claude, Cursor or Gemini CLI: run commands, read, write and search files, run long processes. Your computer only makes an outgoing connection (no open ports or VPN). Read-only mode, allowed folders, blocked commands and an action log keep you in control. Free plan available.
Your own computer's files from ChatGPT or Claude: folder rules, confirmations and undo.
Related MCP Servers
- AlicenseAqualityBmaintenanceProvides Claude Desktop with direct access to your local file system for development tasks, enabling file operations (read, write, edit), directory browsing, command execution, and codebase search within a configured projects directory.6MIT
- FlicenseNot gradedqualityDmaintenanceProvides filesystem access to Claude via the MCP protocol, enabling local file operations through natural language.-
- FlicenseBqualityDmaintenanceEnables local file reading and writing for your project via Claude Desktop, with tools to read, write, and list files in a specified root path.71-
- FlicenseNot gradedqualityBmaintenanceEnables Claude Desktop or other MCP clients to execute shell commands, read/write files, and list directories on the local machine. Includes basic safety guardrails to block obviously destructive operations.-