Skip to content

Commit 00bb3e9

Browse files
authored
fix: add completions capability for Cursor compatibility (#209)
* fix: add completions capability for Cursor compatibility Add completions capability and return empty completions for unsupported types instead of throwing errors. This fixes Cursor startup failures when MCP servers require the completions capability. Related to: eyaltoledano/claude-task-master#1413 * style: fix prettier formatting * add tests to prevent regression of cursor completions issue * fix: advertise completions capability for Cursor compatibility Add completions capability to server capabilities to prevent Cursor from failing to start when the capability is not advertised.
1 parent 6afb0e2 commit 00bb3e9

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

src/FastMCP.test.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1812,6 +1812,45 @@ test("completes template resource arguments", async () => {
18121812
});
18131813
});
18141814

1815+
test("advertises completions capability to prevent Cursor startup error", async () => {
1816+
await runWithTestServer({
1817+
run: async ({ client }) => {
1818+
// The server should advertise completions capability, allowing Cursor to start
1819+
// Verify that completion requests are handled (capability is advertised)
1820+
// by attempting a completion request - it should not throw "method not found"
1821+
try {
1822+
await client.complete({
1823+
argument: {
1824+
name: "test",
1825+
value: "value",
1826+
},
1827+
ref: {
1828+
name: "nonexistent-prompt",
1829+
type: "ref/prompt",
1830+
},
1831+
});
1832+
} catch (error) {
1833+
// It's okay if it throws an error about unknown prompt
1834+
// The important thing is it doesn't throw "method not found"
1835+
// which would indicate the capability isn't advertised
1836+
if (error instanceof McpError) {
1837+
expect(error.code).not.toBe(ErrorCode.MethodNotFound);
1838+
}
1839+
// If it's not an McpError (e.g., UnexpectedStateError), that's fine too
1840+
// It means the method exists and the capability is advertised
1841+
}
1842+
},
1843+
server: async () => {
1844+
const server = new FastMCP({
1845+
name: "Test",
1846+
version: "1.0.0",
1847+
});
1848+
1849+
return server;
1850+
},
1851+
});
1852+
});
1853+
18151854
test("lists resource templates", async () => {
18161855
await runWithTestServer({
18171856
run: async ({ client }) => {

src/FastMCP.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1048,6 +1048,8 @@ export class FastMCPSession<
10481048

10491049
this.#capabilities.logging = {};
10501050

1051+
this.#capabilities.completions = {};
1052+
10511053
this.#server = new Server(
10521054
{ name: name, version: version },
10531055
{ capabilities: this.#capabilities, instructions: instructions },

0 commit comments

Comments
 (0)