roslyn-codelens-mcp 2.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # roslyn-codelens-mcp
2
+
3
+ npm launcher for [Roslyn CodeLens](https://github.com/MarcelRoozekrans/roslyn-codelens-mcp) — a Roslyn-based MCP server that gives AI agents deep semantic understanding of .NET codebases.
4
+
5
+ ```bash
6
+ npx -y roslyn-codelens-mcp
7
+ ```
8
+
9
+ This package contains no server code. It is a thin shim that ensures the
10
+ [`RoslynCodeLens.Mcp`](https://www.nuget.org/packages/RoslynCodeLens.Mcp) .NET global tool is
11
+ installed at the matching version, then execs it. **The .NET 10 SDK must be on `PATH`.**
12
+
13
+ ## MCP client config
14
+
15
+ ```json
16
+ {
17
+ "mcpServers": {
18
+ "roslyn-codelens": {
19
+ "type": "stdio",
20
+ "command": "npx",
21
+ "args": ["-y", "roslyn-codelens-mcp"]
22
+ }
23
+ }
24
+ }
25
+ ```
26
+
27
+ Solution paths can be passed as extra `args`; without them the server walks up from the working
28
+ directory to discover `.sln`/`.slnx` files.
29
+
30
+ If you already have the .NET SDK and prefer no npm indirection, install the tool directly:
31
+
32
+ ```bash
33
+ dotnet tool install -g RoslynCodeLens.Mcp
34
+ ```
35
+
36
+ See the [full documentation](https://marcelroozekrans.github.io/roslyn-codelens-mcp/) for the tool
37
+ catalog, runtime configuration, and the analyzer trust model.
38
+
39
+ MIT licensed.
@@ -0,0 +1,138 @@
1
+ #!/usr/bin/env node
2
+
3
+ // Launcher for the RoslynCodeLens.Mcp .NET global tool.
4
+ //
5
+ // This package ships no server code. It exists so the server can be started with
6
+ // `npx -y roslyn-codelens-mcp` by clients and directories that only know how to run
7
+ // npm-hosted MCP servers. Everything it does is: verify the .NET SDK is present,
8
+ // make sure the global tool matches this package's version, then exec it.
9
+ //
10
+ // stdout is the JSON-RPC channel, so every diagnostic and every byte of dotnet's
11
+ // install output goes to stderr.
12
+
13
+ const { execFileSync, spawn } = require("node:child_process");
14
+ const fs = require("node:fs");
15
+ const os = require("node:os");
16
+ const path = require("node:path");
17
+
18
+ const PACKAGE_ID = "RoslynCodeLens.Mcp";
19
+ const COMMAND = "roslyn-codelens-mcp";
20
+ const { version } = require("../package.json");
21
+
22
+ function fail(message) {
23
+ process.stderr.write(`roslyn-codelens-mcp: ${message}\n`);
24
+ process.exit(1);
25
+ }
26
+
27
+ function hasDotnet() {
28
+ try {
29
+ execFileSync("dotnet", ["--version"], { stdio: "ignore" });
30
+ return true;
31
+ } catch {
32
+ return false;
33
+ }
34
+ }
35
+
36
+ // The installed version of the global tool, or null when it is not installed.
37
+ // `dotnet tool list --global` lowercases the package id and prints it as
38
+ // `roslyncodelens.mcp 2.14.0 roslyn-codelens-mcp`. Local lookup — no network.
39
+ function installedVersion() {
40
+ try {
41
+ const output = execFileSync("dotnet", ["tool", "list", "--global"], {
42
+ encoding: "utf8",
43
+ stdio: ["ignore", "pipe", "ignore"],
44
+ });
45
+ for (const line of output.split("\n")) {
46
+ const match = line.match(/^roslyncodelens\.mcp\s+(\S+)/i);
47
+ if (match) {
48
+ return match[1];
49
+ }
50
+ }
51
+ } catch {
52
+ // dotnet missing or the command failed — treat the tool as not installed.
53
+ }
54
+ return null;
55
+ }
56
+
57
+ // `dotnet tool install` fails when a different version is already present, so the
58
+ // verb depends on what is there. Output is routed to stderr (fd 2) rather than
59
+ // captured so a slow first-run restore still shows progress.
60
+ function install(alreadyInstalled) {
61
+ const verb = alreadyInstalled ? "update" : "install";
62
+ process.stderr.write(
63
+ `roslyn-codelens-mcp: ${verb === "install" ? "installing" : "updating"} ${PACKAGE_ID} ${version}...\n`
64
+ );
65
+ execFileSync(
66
+ "dotnet",
67
+ ["tool", verb, "--global", PACKAGE_ID, "--version", version],
68
+ { stdio: ["ignore", 2, 2] }
69
+ );
70
+ }
71
+
72
+ // Global tools land in ~/.dotnet/tools, which is not necessarily on PATH — notably
73
+ // in the same process that just installed them. Resolve the executable directly and
74
+ // prepend the directory for the child so any tool-to-tool lookup also works.
75
+ function toolsDir() {
76
+ return (
77
+ process.env.DOTNET_TOOLS_PATH ||
78
+ path.join(process.env.DOTNET_CLI_HOME || os.homedir(), ".dotnet", "tools")
79
+ );
80
+ }
81
+
82
+ function resolveExecutable() {
83
+ const dir = toolsDir();
84
+ const name = process.platform === "win32" ? `${COMMAND}.exe` : COMMAND;
85
+ const candidate = path.join(dir, name);
86
+ return fs.existsSync(candidate) ? candidate : COMMAND;
87
+ }
88
+
89
+ function launch() {
90
+ const dir = toolsDir();
91
+ const child = spawn(resolveExecutable(), process.argv.slice(2), {
92
+ stdio: "inherit",
93
+ env: {
94
+ ...process.env,
95
+ PATH: `${dir}${path.delimiter}${process.env.PATH || ""}`,
96
+ },
97
+ });
98
+
99
+ for (const signal of ["SIGINT", "SIGTERM"]) {
100
+ process.on(signal, () => child.kill(signal));
101
+ }
102
+
103
+ child.on("error", (err) => fail(`failed to start ${COMMAND}: ${err.message}`));
104
+ child.on("exit", (code, signal) => {
105
+ if (signal) {
106
+ process.kill(process.pid, signal);
107
+ return;
108
+ }
109
+ process.exit(code ?? 0);
110
+ });
111
+ }
112
+
113
+ if (!hasDotnet()) {
114
+ fail(
115
+ "the .NET SDK was not found on PATH. RoslynCodeLens requires the .NET 10 SDK — https://dotnet.microsoft.com/download"
116
+ );
117
+ }
118
+
119
+ const current = installedVersion();
120
+
121
+ // Already on the matching version — skip the install round-trip entirely so startup
122
+ // stays fast and works offline.
123
+ if (current !== version) {
124
+ try {
125
+ install(current !== null);
126
+ } catch (err) {
127
+ if (current === null) {
128
+ fail(`failed to install ${PACKAGE_ID} ${version}: ${err.message}`);
129
+ }
130
+ // A version mismatch is not fatal when a working tool is already present:
131
+ // an offline or rate-limited NuGet should not take the server down.
132
+ process.stderr.write(
133
+ `roslyn-codelens-mcp: could not update to ${version}, continuing with installed ${current}\n`
134
+ );
135
+ }
136
+ }
137
+
138
+ launch();
package/package.json ADDED
@@ -0,0 +1,38 @@
1
+ {
2
+ "name": "roslyn-codelens-mcp",
3
+ "version": "2.14.0",
4
+ "description": "Roslyn-based MCP server that gives AI agents deep semantic understanding of .NET codebases — navigation, call graphs, diagnostics, refactoring, code-quality auditing, test intelligence, and IL inspection.",
5
+ "bin": {
6
+ "roslyn-codelens-mcp": "./bin/roslyn-codelens-mcp.js"
7
+ },
8
+ "files": [
9
+ "bin",
10
+ "README.md"
11
+ ],
12
+ "keywords": [
13
+ "mcp",
14
+ "mcp-server",
15
+ "modelcontextprotocol",
16
+ "roslyn",
17
+ "csharp",
18
+ "dotnet",
19
+ "code-analysis",
20
+ "code-intelligence",
21
+ "static-analysis",
22
+ "refactoring"
23
+ ],
24
+ "license": "MIT",
25
+ "author": "Marcel Roozekrans",
26
+ "homepage": "https://marcelroozekrans.github.io/roslyn-codelens-mcp/",
27
+ "repository": {
28
+ "type": "git",
29
+ "url": "git+https://github.com/MarcelRoozekrans/roslyn-codelens-mcp.git"
30
+ },
31
+ "bugs": {
32
+ "url": "https://github.com/MarcelRoozekrans/roslyn-codelens-mcp/issues"
33
+ },
34
+ "mcpName": "io.github.MarcelRoozekrans/roslyn-codelens",
35
+ "engines": {
36
+ "node": ">=18"
37
+ }
38
+ }