Skip to content

Commit fb4b52b

Browse files
authored
Merge pull request #179 from WolframResearch/feature/DetectedMCPClients
Initial implementation of DetectedMCPClients[]
2 parents 240029a + 9ca5958 commit fb4b52b

6 files changed

Lines changed: 94 additions & 0 deletions

File tree

Kernel/Main.wl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ System`DeployAgentTools;
2323
`CodeInspectorToolFunction;
2424
`CreateMCPServer;
2525
`CreatePreferencesContent;
26+
`DetectedMCPClients;
2627
`InstallMCPServer;
2728
`MCPServerObject;
2829
`MCPServerObjectQ;
@@ -108,6 +109,7 @@ $AgentToolsProtectedNames = "Wolfram`AgentTools`" <> # & /@ {
108109
"CodeInspectorToolFunction",
109110
"CreateMCPServer",
110111
"CreatePreferencesContent",
112+
"DetectedMCPClients",
111113
"InstallMCPServer",
112114
"MCPServerObject",
113115
"MCPServerObjectQ",

Kernel/SupportedClients.wl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,19 @@ $SupportedMCPClients := WithCleanup[
1515
Protect @ $SupportedMCPClients
1616
];
1717

18+
(* ::**************************************************************************************************************:: *)
19+
(* ::Section::Closed:: *)
20+
(*DetectedMCPClients*)
21+
DetectedMCPClients // beginDefinition;
22+
23+
DetectedMCPClients[ ] :=
24+
catchMine @ KeySelect[
25+
$SupportedMCPClients,
26+
Quiet @ FileExistsQ @ catchAlways @ installLocation[ # ] &
27+
];
28+
29+
DetectedMCPClients // endExportedDefinition;
30+
1831
(* ::**************************************************************************************************************:: *)
1932
(* ::Subsection::Closed:: *)
2033
(*$supportedMCPClients*)

PacletInfo.wl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ PacletObject[ <|
3737
"Wolfram`AgentTools`CodeInspectorToolFunction",
3838
"Wolfram`AgentTools`CreateMCPServer",
3939
"Wolfram`AgentTools`CreatePreferencesContent",
40+
"Wolfram`AgentTools`DetectedMCPClients",
4041
"Wolfram`AgentTools`InstallMCPServer",
4142
"Wolfram`AgentTools`MCPServerObject",
4243
"Wolfram`AgentTools`MCPServerObjectQ",

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ CreateMCPServer["My MCP Server", <|
273273
| `InstallMCPServer[client, server]` | Install a specific server for a client |
274274
| `UninstallMCPServer[client]` | Remove all servers from a client |
275275
| `UninstallMCPServer[client, name]` | Remove a specific server from a client |
276+
| `DetectedMCPClients[]` | Subset of `$SupportedMCPClients` whose config file exists on this machine |
276277
| `DeployAgentTools[target]` | Deploy tools to a client with tracked deployment management |
277278
| `DeployAgentTools[All]` | Deploy tools to every client in `$SupportedMCPClients` (see [docs/deploy-agent-tools.md](docs/deploy-agent-tools.md#deploying-to-all-clients)) |
278279
| `ValidateAgentToolsPacletExtension[paclet]` | Validate an `"AgentTools"` paclet extension |

Tests/SupportedClients.wlt

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
(* ::**************************************************************************************************************:: *)
2+
(* ::Section::Closed:: *)
3+
(*Initialization*)
4+
VerificationTest[
5+
Needs[ "Wolfram`AgentToolsTests`", FileNameJoin @ { DirectoryName @ $TestFileName, "Common.wl" } ],
6+
Null,
7+
SameTest -> MatchQ,
8+
TestID -> "GetDefinitions@@Tests/SupportedClients.wlt:4,1-9,2"
9+
]
10+
11+
VerificationTest[
12+
Needs[ "Wolfram`AgentTools`" ],
13+
Null,
14+
SameTest -> MatchQ,
15+
TestID -> "LoadContext@@Tests/SupportedClients.wlt:11,1-16,2"
16+
]
17+
18+
(* ::**************************************************************************************************************:: *)
19+
(* ::Section::Closed:: *)
20+
(*DetectedMCPClients*)
21+
22+
(* ::**************************************************************************************************************:: *)
23+
(* ::Subsection::Closed:: *)
24+
(*Returns an association of supported client metadata keyed by canonical name*)
25+
VerificationTest[
26+
DetectedMCPClients[ ],
27+
KeyValuePattern[ { } ]?AssociationQ,
28+
SameTest -> MatchQ,
29+
TestID -> "DetectedMCPClients-ReturnShape@@Tests/SupportedClients.wlt:25,1-30,2"
30+
]
31+
32+
(* ::**************************************************************************************************************:: *)
33+
(* ::Subsection::Closed:: *)
34+
(*All detected names are valid supported clients*)
35+
VerificationTest[
36+
SubsetQ[ Keys @ $SupportedMCPClients, Keys @ DetectedMCPClients[ ] ],
37+
True,
38+
TestID -> "DetectedMCPClients-Subset@@Tests/SupportedClients.wlt:36,1-40,2"
39+
]
40+
41+
(* ::**************************************************************************************************************:: *)
42+
(* ::Subsection::Closed:: *)
43+
(*Result preserves the ordering of $SupportedMCPClients*)
44+
VerificationTest[
45+
With[ { detected = DetectedMCPClients[ ] },
46+
Keys[ detected ] === Select[ Keys @ $SupportedMCPClients, KeyExistsQ[ detected, # ] & ]
47+
],
48+
True,
49+
TestID -> "DetectedMCPClients-Ordering@@Tests/SupportedClients.wlt:46,1-50,2"
50+
]
51+
52+
(* ::**************************************************************************************************************:: *)
53+
(* ::Subsection::Closed:: *)
54+
(*Invalid arguments*)
55+
VerificationTest[
56+
DetectedMCPClients[ "bogus" ],
57+
_Failure,
58+
{ DetectedMCPClients::InvalidArguments },
59+
SameTest -> MatchQ,
60+
TestID -> "DetectedMCPClients-InvalidArguments@@Tests/SupportedClients.wlt:57,1-63,2"
61+
]

docs/mcp-clients.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,22 @@ $SupportedMCPClients["ClaudeDesktop"]
578578
(* <|"Aliases" -> {"Claude"}, "ConfigFormat" -> "JSON", "ConfigKey" -> {"mcpServers"}, ...|> *)
579579
```
580580

581+
### Detecting Installed Clients
582+
583+
`DetectedMCPClients[]` returns the subset of `$SupportedMCPClients` whose user-scope config file exists on the current machine — a quick way to discover which supported clients are actually installed before calling `InstallMCPServer`.
584+
585+
```wl
586+
(* Names of clients that appear to be installed locally *)
587+
Keys @ DetectedMCPClients[ ]
588+
(* {"ClaudeCode", "Cursor", "VisualStudioCode", ...} *)
589+
590+
(* Full metadata for detected clients *)
591+
DetectedMCPClients[ ]
592+
(* <|"ClaudeCode" -> <|...|>, "Cursor" -> <|...|>, ...|> *)
593+
```
594+
595+
The result is keyed by canonical client name and preserves the ordering of `$SupportedMCPClients`. Detection is based purely on the existence of each client's `"InstallLocation"` config file for the current `$OperatingSystem`; project-scope config files (`"ProjectPath"`) are not checked.
596+
581597
## Adding Support for New Clients
582598

583599
All client configuration is centralized in `$supportedMCPClients` in `Kernel/SupportedClients.wl`. To add support for a new MCP client, add an entry to this association.

0 commit comments

Comments
 (0)