Prompt Completion
👨💼 As the user searches through the dynamic values it can input for the prompt,
it would be nice to have auto-completion of values.
We'll use the
completable
function to create a completable prompt.import { completable } from '@modelcontextprotocol/sdk/server/completable.js'
// ...
agent.server.registerPrompt(
'say_hello',
{
title: 'Say hello to the user',
description: 'Say hello to the user',
argsSchema: {
name: completable(
z.string().describe('The name of the user to say hello to'),
async (value) => {
const users = await agent.db.getUsers()
return users
.map((user) => user.name)
.filter((name) => name.includes(value))
},
),
},
async ({ name }) => {
// ... return prompt messages
},
)