Skip to content

Commit 93d734b

Browse files
committed
hook up the global identifier command
1 parent 32b6fe8 commit 93d734b

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

analysis/bin/main.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ let main () =
113113
| [_; "mcp"; "loc-info"; path; line; col] ->
114114
Mcp.LocInfo.locInfo ~path ~pos:(int_of_string line, int_of_string col)
115115
|> print_endline
116-
| [_; "mcp"; "identifier-info"; identifier; path] ->
116+
| [_; "mcp"; "identifier-info"; path; identifier] ->
117117
Mcp.IdentifierInfo.identifierInfo ~identifier ~path ~maybe_line:None
118118
~maybe_col:None
119119
|> print_endline

mcp/server.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,41 @@ server.tool(
7373
}
7474
);
7575

76+
server.tool(
77+
"find_type_of_global_identifier",
78+
{
79+
filePath: z.string().describe("Absolute path to the ReScript file"),
80+
identifier: z.string().describe("The identifier to find the type of"),
81+
},
82+
{
83+
destructiveHint: false,
84+
idempotentHint: true,
85+
readOnlyHint: true,
86+
title: `Finds the type of a global identifier, like \`SomeModule.SomeNestedModule.someValue\` or \`React.createElement\`.
87+
88+
- **Always** use the fully qualified global path. Even if you are in \`SomeModule.res\` and are looking for \`x\` in that file, use the fully qualified path \`SomeModule.x\`.`,
89+
},
90+
({ filePath, identifier }) => {
91+
try {
92+
const result = execAnalysis([
93+
"mcp",
94+
"identifier-info",
95+
filePath,
96+
identifier,
97+
]);
98+
return {
99+
content: [{ type: "text", text: result ?? "No result." }],
100+
};
101+
} catch (error) {
102+
return {
103+
content: [
104+
{ type: "text", text: `Error finding type definition: ${error}` },
105+
],
106+
};
107+
}
108+
}
109+
);
110+
76111
// Main function to start the server
77112
async function main() {
78113
try {

0 commit comments

Comments
 (0)