claude-roslyn-lsp MCP配置与使用教程
io.github.lahma/claude-roslyn-lsp · v1.0.0
C# semantic rename, code actions, fix-all, formatting and diagnostics via Microsoft's Roslyn server
建议先在本页复制安装配置,再到上游核对文档与权限。
产品介绍
C# semantic rename, code actions, fix-all, formatting and diagnostics via Microsoft's Roslyn server claude-roslyn-lsp 是一个MCP Server,收录自 官方 MCP Registry。支持 stdio 传输。本页提供产品介绍、配置教程、安装命令与适用场景,支持 Trae、通义灵码、Cursor、Claude Code、VS Code 等。
适用场景
AgentHub Verified 可用性验证技术测试通过
自动化测试流水线已校验安装命令、传输协议与客户端兼容性
常见报错排查与运行避坑 (Troubleshooting)FAQ
针对 claude-roslyn-lsp 在 Cursor、Claude Code 中的常见连接错误与解决办法
在 Cursor / Claude Code 中配置 claude-roslyn-lsp 提示 connection closed 或 exit code 1?
通常由本地运行时环境缺失或命令路径未被 IDE 继承引起。排查步骤: 1. 确认已安装 Node.js 18+(支持 npx)或 Python 3.10+(支持 uvx); 2. 尝试在终端运行 which npx 或 which uvx,把配置文件中的 "command" 字段改为完整绝对路径; 3. 修改 mcp.json 后,必须完全重载或重启客户端窗口。
# 终端测试命令是否存在: which npx node -v
提示 spawn npx ENOENT 或 command not found?
这是因为编辑器后台进程未加载完整的终端环境变量(PATH)。解决方案:在全局安装该包(如 npm install -g 包名),或在配置文件中将 command 设置为系统的实际路径(如 Windows 下的 C:\Program Files\nodejs\npx.cmd,Mac 下的 /usr/local/bin/npx)。
提示 Missing required environment variable 或 API 认证失败?
claude-roslyn-lsp 依赖环境变量(如 CLAUDE_ROSLYN_LSP_SOLUTION、CLAUDE_ROSLYN_LSP_ROSLYN_PATH、CLAUDE_ROSLYN_LSP_ROSLYN_VERSION、CLAUDE_ROSLYN_LSP_ROSLYN_ARGS、CLAUDE_ROSLYN_LSP_CACHE_DIR、CLAUDE_ROSLYN_LSP_HOME、CLAUDE_ROSLYN_LSP_OFFLINE、CLAUDE_ROSLYN_LSP_TRANSPORT、CLAUDE_ROSLYN_LSP_READY_TIMEOUT_SECONDS、CLAUDE_ROSLYN_LSP_DIAGNOSTICS、CLAUDE_ROSLYN_LSP_DIAGNOSTIC_MIN_SEVERITY、CLAUDE_ROSLYN_LSP_WORKSPACE_DIAGNOSTICS、CLAUDE_ROSLYN_LSP_FILE_WATCHER、CLAUDE_ROSLYN_LSP_SHARE、CLAUDE_ROSLYN_LSP_GC、CLAUDE_ROSLYN_LSP_GC_CONSERVE、CLAUDE_ROSLYN_LSP_IDLE_RECYCLE_MINUTES、CLAUDE_ROSLYN_LSP_RECYCLE_GROWTH_FACTOR、CLAUDE_ROSLYN_LSP_IDLE_SHUTDOWN_MINUTES、CLAUDE_ROSLYN_LSP_LOG_LEVEL、CLAUDE_ROSLYN_LSP_ROSLYN_LOG_LEVEL、CLAUDE_ROSLYN_LSP_OPTIONS)。请在客户端配置文件的 "env" 对象中填入有效密钥,注意不要包含多余空格或未闭合的双引号。
// .cursor/mcp.json 或 claude_desktop_config.json
{
"env": {
"API_KEY": "your_actual_key_here"
}
}免安装模拟调用 (Playground)
仿真环境claude-roslyn-lsp 核心接口调用仿真 · 无需配置本地环境,直接预览调用参数与返回格式
{
"target": "claude-roslyn-lsp",
"action": "execute",
"options": {
"mode": "standard",
"timeoutMs": 5000
}
}点击上方「模拟运行」按钮
查看该工具在 Agent 内部的返回数据格式
选型与决策建议(为什么选它?)
帮助你快速判断该资源是否契合当前项目,避免盲目折腾
- PR 自动审查
- 生成 changelog
- 跨仓库 Issue 检索
- 替代人工安全审计
- 在无授权仓库上操作
claude-roslyn-lsp + 对应场景 Prompt → 组成标准 Agent 自动化任务
MCP 实战教程:从安装到看见效果
按完整实例走一遍(含期望效果与对比验收)。装完本页资源后,用教程里的提示词核对是否真正生效。
相关资源
ssh-mcp-pro 安全 SSH 自动化
v1.17.0
io.github.oaslananka/ssh-mcp-pro
安全的 MCP SSH 自动化服务器,具备策略管控、资源、提示词,支持 stdio 与 HTTP。
flint
v1.19.6
io.github.synuns/flint
Agent long-term memory with search, recording, and hot injection for AI coding agents
Agent Data Tools: Web, documents and search
v1.331.0
io.github.Nutshell2000/agent-data-tools-web
30 tools: web pages, JS apps and PDFs as text, feeds, sitemaps, search. 10 free calls.
Agent Data Tools: Speech to text and text to speech
v1.331.0
io.github.Nutshell2000/agent-data-tools-voice
Transcribe audio and video (SRT/VTT subtitles, an hour for $0.05) and text to speech as MP3.
Agent Data Tools: Utilities
v1.331.0
io.github.Nutshell2000/agent-data-tools-utilities
109 tools: JSON repair, CSV, hashes, cron, dates, units, validators. 10 free calls.
Agent Data Tools: Prices and DeFi
v1.331.0
io.github.Nutshell2000/agent-data-tools-prices
53 tools: token prices, wallet and contract risk, liquidity pools, FX. 10 free calls.
常搭配使用
中国大陆 AI 保险顾问
v2.4.21
io.clawhub.mnetfairy/insurance-advisor-china
中国大陆AI保险顾问。为个人和家庭提供全方位的保险咨询、产品对比、方案设计、投保指导。当用户询问保险配置、保险方案、产品对比、重疾险/医疗险/寿险/意外险/储蓄险推荐、保费计算、保障缺口分析、需求分析、核保合规、理赔等问题时使用。
AI 保险顾问(中国大陆)
v2.4.21
io.clawhub.mnetfairy/ai-insurance-advisor
中国大陆保险顾问。本 skill 仅覆盖 6 项实际实现的能力:保险需求分析(needs_analyzer.py)、产品对比(premium_calculator.py + 本地 products.json)、保费计算(premium_calculator.py)、方案设计(plan_designer.py)、保险知识问答(insurance-knowledge.md)、合规要点提示(compliance.md)。不提供核保预审、理赔代办、朋友圈/营销文案生成、培训话术、代理人展业工具等能力——这些场景请转人工或调用专业服务。
中文公文写作
v2.0.63
io.clawhub.gongyu0918-debug/chinese-official-writing
用于中文公文、事务性材料和新闻稿件的起草、改写、压缩、润色、审校、文种核对、去口语化、降 AI 味及 Word 格式处理,适用于机关、企事业单位、学校和新闻机构。涵盖申请、请示、报告、通知、通告、意见、决定、决议、议案、公报、命令、函、复函、批复、说明、方案、纪要、公告、公示、通报、制度、规定、办法、细则、操作规程、工作要点、总结、调研、讲话、致辞、主持词、述职、可研、审查材料、技术需求、新闻消息、编者按、新闻评论,以及采购、整改、反馈和 AI 算力等场景。
Free Ride - 无限免费 AI
v1.1.0
io.clawhub.shaivpidadi/free-ride
为 OpenClaw 管理 OpenRouter 的免费 AI 模型。
继续逛 AgentHub
大多数人安装前还会对比同类工具或看场景方案——下面这些能帮你少走弯路。
收录徽章:把 AgentHub 挂到你的官网
复制下面任意一段代码到项目主页、官网或 GitHub README。徽章是 SVG 热链,无需上传文件,链接指向本页,访客可由此直接找到安装方式。
<a href="https://myagenthub.cn/p/io.github.lahma/claude-roslyn-lsp" title="AgentHub 已收录:claude-roslyn-lsp" target="_blank" rel="noopener">
<img src="https://myagenthub.cn/badge/io.github.lahma/claude-roslyn-lsp" alt="AgentHub 已收录:claude-roslyn-lsp" height="20" style="border:0"/>
</a>[](https://myagenthub.cn/p/io.github.lahma/claude-roslyn-lsp)徽章由 /badge/<资源ID> 动态生成,名称与收录状态变化后自动更新;请保留链接指向,它是收录来源的判定依据。
统一 Manifest
{
"id": "io.github.lahma/claude-roslyn-lsp",
"type": "mcp-server",
"version": "1.0.0",
"displayName": "claude-roslyn-lsp",
"description": "C# semantic rename, code actions, fix-all, formatting and diagnostics via Microsoft's Roslyn server",
"repository": {
"url": "https://github.com/lahma/claude-roslyn-lsp",
"source": "github"
},
"distribution": {
"packages": [
{
"registryType": "nuget",
"identifier": "claude-roslyn-lsp",
"version": "1.0.0",
"transport": "stdio",
"environmentVariables": [
{
"name": "CLAUDE_ROSLYN_LSP_SOLUTION",
"description": "Path to the .slnx, .sln or .csproj to load. Optional: the adapter discovers one from the working directory, honouring .vscode/settings.json's dotnet.defaultSolution. Set it in a monorepo, where discovery picks a solution that is often not the one being worked in. A path that does not exist is a startup failure rather than a fall back to discovery."
},
{
"name": "CLAUDE_ROSLYN_LSP_ROSLYN_PATH",
"description": "Directory holding an already-installed Microsoft.CodeAnalysis.LanguageServer.dll, used instead of downloading one. Optional; set it to run air-gapped or against a locally built server. Its version is not checked. Alias: CLAUDE_ROSLYN_LSP_SERVER_PATH."
},
{
"name": "CLAUDE_ROSLYN_LSP_ROSLYN_VERSION",
"description": "Overrides the pinned roslyn-language-server version the adapter downloads from nuget.org. Optional; the pin is the only version this release is tested against, an override has no hash to verify against, and doctor reports it as unverified. Alias: CLAUDE_ROSLYN_LSP_SERVER_VERSION."
},
{
"name": "CLAUDE_ROSLYN_LSP_ROSLYN_ARGS",
"description": "Extra arguments for the Roslyn child process, split on whitespace with no quoting. Development only: it exists so the smoke test can point the launcher at this binary's own scripted backend."
},
{
"name": "CLAUDE_ROSLYN_LSP_CACHE_DIR",
"description": "Where downloaded Roslyn servers are extracted. Optional; defaults to a directory under the adapter's home. Moves the payloads only - logs and staged downloads stay under the home."
},
{
"name": "CLAUDE_ROSLYN_LSP_HOME",
"description": "The adapter's per-user state directory: downloads, logs and lock files. Optional; unset, it falls back to CLAUDE_PLUGIN_DATA and then to the platform cache location (%LOCALAPPDATA%, ~/Library/Caches, $XDG_CACHE_HOME or ~/.cache). Around 140 MB extracted per Roslyn version per platform, so it belongs on a disk with room and outside a roaming profile."
},
{
"name": "CLAUDE_ROSLYN_LSP_OFFLINE",
"description": "Set to 1 to refuse to download a Roslyn server. A missing cache entry becomes an immediate, explained failure instead of a 70 MB fetch. Accepts 1/true/yes/on and 0/false/no/off; default 0."
},
{
"name": "CLAUDE_ROSLYN_LSP_TRANSPORT",
"description": "How the adapter talks to the Roslyn child process: pipe (default) or stdio. The named pipe is preferred because Roslyn writes a startup banner to its own stdout, which under stdio shares a stream with the protocol."
},
{
"name": "CLAUDE_ROSLYN_LSP_READY_TIMEOUT_SECONDS",
"description": "How long a call waits for the workspace to finish loading before it is answered anyway, 1-3600, default 120. Tools report status \"loading\" rather than hanging while they wait."
},
{
"name": "CLAUDE_ROSLYN_LSP_DIAGNOSTICS",
"description": "The pull-to-push diagnostics bridge, on by default. Applies to the lsp verb only: an MCP client asks for diagnostics with getDiagnostics instead. Accepts 1/true/yes/on and 0/false/no/off."
},
{
"name": "CLAUDE_ROSLYN_LSP_DIAGNOSTIC_MIN_SEVERITY",
"description": "The severity floor applied before diagnostics are pushed to an LSP client: error, warning (default), information or hint. The MCP getDiagnostics tool takes its own minSeverity argument instead."
},
{
"name": "CLAUDE_ROSLYN_LSP_WORKSPACE_DIAGNOSTICS",
"description": "Opt-in workspace-wide diagnostics for files that are not open, for the lsp verb. Off unless set, because it needs a full-solution compiler scope, which is what makes a large solution slow."
},
{
"name": "CLAUDE_ROSLYN_LSP_FILE_WATCHER",
"description": "The file-watch bridge, on by default. Without it a file created by a shell command or by git never joins its project and every later answer is silently stale. Accepts 1/true/yes/on and 0/false/no/off."
},
{
"name": "CLAUDE_ROSLYN_LSP_SHARE",
"description": "Whether the lsp and mcp servers share one Roslyn per solution, on by default. Off makes each of them launch a Roslyn of its own, which loads the solution twice and pays for it twice in memory. getWorkspaceStatus reports engine: owned or attached, so which of the two happened is never a guess."
},
{
"name": "CLAUDE_ROSLYN_LSP_GC",
"description": "Which garbage collector the Roslyn child runs with: workstation (the default) or server. Workstation peaks at about 577 MB on a 239-project solution where server peaks at about 2 GB, and costs about 8 seconds of load time. An explicit DOTNET_gcServer in the environment wins over this."
},
{
"name": "CLAUDE_ROSLYN_LSP_GC_CONSERVE",
"description": "The DOTNET_GCConserveMemory level, 0-9, the Roslyn child runs with: it caps how far the child's heap may grow past its live data, so less free space stays committed after a compacting collection. Default 7; 0 sets nothing. An explicit DOTNET_GCConserveMemory in the environment wins over this."
},
{
"name": "CLAUDE_ROSLYN_LSP_IDLE_RECYCLE_MINUTES",
"description": "How long the session has to be idle before a Roslyn child that has grown past its threshold is stopped to give its memory back; the next call relaunches it and waits for the reload. Default 20; 0 switches the recycle off."
},
{
"name": "CLAUDE_ROSLYN_LSP_RECYCLE_GROWTH_FACTOR",
"description": "How far past its post-load baseline the Roslyn child has to have grown before an idle recycle is worth a reload: the threshold is the larger of baseline times this factor and baseline plus 512 MB. A decimal, 1.2-20, default 2."
},
{
"name": "CLAUDE_ROSLYN_LSP_IDLE_SHUTDOWN_MINUTES",
"description": "Stop the Roslyn child after this many idle minutes whatever its size; the next call relaunches it. Default 0, which is off, because every relaunch costs a full solution load."
},
{
"name": "CLAUDE_ROSLYN_LSP_LOG_LEVEL",
"description": "Trace, Debug, Information, Warning, Error, Critical or None (default Information). Logs go to stderr only - stdout is the JSON-RPC channel."
},
{
"name": "CLAUDE_ROSLYN_LSP_ROSLYN_LOG_LEVEL",
"description": "The level handed to the Roslyn child process, default Warning. Its Information level is about twenty lines of narration per start, all of it on this adapter's stderr."
},
{
"name": "CLAUDE_ROSLYN_LSP_OPTIONS",
"description": "A JSON object merged into the answers the adapter gives Roslyn's workspace/configuration requests, for the sections the defaults get wrong for your repository. A syntax error is a logged warning, never a startup failure."
}
]
}
],
"remotes": []
},
"dependencies": [],
"installTargets": [
"claude-code",
"claude-desktop",
"cursor",
"vscode",
"trae",
"cherry-studio",
"lingma",
"windsurf",
"cline",
"workbuddy"
],
"keywords": [],
"provenance": {
"origin": "official-mcp-registry",
"originalId": "io.github.lahma/claude-roslyn-lsp",
"originalUrl": "https://registry.modelcontextprotocol.io/v0.1/servers/io.github.lahma%2Fclaude-roslyn-lsp/versions/latest",
"isOfficial": true,
"status": "active"
}
}