Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typing issue with providing required and complete for ResourceTemplate #20

Open
0237h opened this issue Mar 13, 2025 · 0 comments
Open

Comments

@0237h
Copy link

0237h commented Mar 13, 2025

Hi,

Tried running the example for autocomplete of ResourceTemplate and it gives a typing error when the complete function is specified alongside the required property for any of the arguments.

Here's how the type definition looks like with required and no complete:

Image

Code

mcp.addResourceTemplate({
    uriTemplate: "file:///test",
    name: "Test",
    mimeType: "text/plain",
    arguments: [
        {
            name: "a",
            description: "Argument A",
            required: true
        },
        {
            name: "b",
            description: "Argument B",
            required: true
        },
    ],
    load: async ({ a, b }) => {
        // ...
    },
});

Here's how the type definition looks like with complete and no required:

Image

Code

mcp.addResourceTemplate({
    uriTemplate: "file:///test",
    name: "Test",
    mimeType: "text/plain",
    arguments: [
        {
            name: "a",
            description: "Argument A",
            complete: async (value) => {
                // ...
            },
        },
        {
            name: "b",
            description: "Argument B",
            complete: async (value) => {
                // ...
            },
        },
    ],
    load: async ({ a, b }) => {
        // ...
    },
});

And here's the typing when adding required to any of the two arguments:

Image

Code

mcp.addResourceTemplate({
    uriTemplate: "file:///test",
    name: "Test",
    mimeType: "text/plain",
    arguments: [
        {
            name: "a",
            description: "Argument A",
            required: true,
            complete: async (value) => {
                // ...
            },
        },
        {
            name: "b",
            description: "Argument B",
            complete: async (value) => {
                // ...
            },
        },
    ],
    load: async ({ a, b }) => {
        // ...
    },
});

With error being:

Object literal may only specify known properties, and 'required' does not exist in type 'Readonly<{ name: string; description?: string | undefined; complete?: ArgumentValueCompleter | undefined; }>

It compiles and run fine though so not a big deal, just a linting error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant