•   about 1 month ago

Enforced code snippet requested?

Hi everyone

On the welcome email the text implies we must implement a exact code snippet, so my question is if this exact code is expected verbatim or it was just an example of a typical implementation? In my the case, my project is built in react/nextjs which ideally will require abstractions like hooks/components or using libraries as react-webmcp, so including this snippet exactly as requested will be very antipattern. Or either what this request meant is that we must expose this specific tool "search_product" so that an automated test can find it as kind-of signature? Please let me know!

Btw the patterns I was willing to use was like:
function SearchTool() {
useMcpTool({
name: "search_products",
description: "Search the product catalog",
input: z.object({ ... }),
handler: async ({ query }) => ({
...
}),
});
return null;
}
export default function App() {
return (



);
}

This is the text as received in the email:
"Repositories should show WebMCP implementation with the following code snippet:
document.modelContext.registerTool({
name: "search_products",
description: "Search the product catalog",
inputSchema: { /* ... */ },
execute: async (input) => { /* ... */ }
});"

  • 1 comment

  • Manager   •   about 1 month ago

    Good question, and no, that snippet is not required verbatim.

    It is an example of the WebMCP API, not code you must copy word for word. You do not need a tool named search_products. That name is just a placeholder for a typical tool.

    What the rules ask for is that your public repo contains "All necessary source code, assets, and instructions required for the project to be functional," and shows a real, working WebMCP implementation.

    Your React pattern is fine. useMcpTool from react-webmcp registers tools through the same underlying API, so it satisfies this. Use whatever abstraction fits your stack.

    Good luck!

Log in or sign up for Devpost to join the conversation.