Resource Template Completions

πŸ‘¨β€πŸ’Ό Now that our users have a bunch of entries and tags, they'll want to be able to search for them. Let's add some completions to our resource templates to make this possible.
This involves a simple callback as a part of our ResourceTemplate definition. For example:
import { ResourceTemplate } from '@modelcontextprotocol/sdk/server/mcp.js'

const NAMES = ['Alice', 'Bob', 'Charlie']

agent.server.registerResource(
	'hello',
	new ResourceTemplate('hello://{name}', {
		complete: {
			// this is an object with a key for each parameter in the resource template
			// it accepts the value the user has typed so far and returns a string array
			// of valid matching values
			async name(value) {
				// this is a function that returns a string array of valid matching values
				// for the `name` parameter
				return NAMES.filter((name) => name.includes(value))
			},
		},
		list: async () => {
			// ...
		},
	}),
	{
		title: 'Hello',
		description: 'Say hello to anyone by name!',
	},
	async (uri, { name }) => {
		// ...
	},
)
You'll also want to add a completions capability to your server.
Test this out by clicking on a resource template and typing in a value for the parameter.

Please set the playground first

Loading "Resource Template Completions"
Loading "Resource Template Completions"
Login to get access to the exclusive discord channel.
  • ⚑General
    Epic MCP Server
    Fede:
    Given the amount of questions around deployment and getting started, it would be cool to have an Epi...
    • βœ…1
    2 Β· a day ago
  • ⚑General
    Cloudflare deployment
    Aaron Schwartz:
    Do you have any resources on deploying to a live cloudflare instance? I haven't dug through the work...
    • πŸ‘1
    • βœ…1
    4 Β· a day ago
  • 🐣MCP Fundamentals
    Resources in Tools
    Alexandre πŸš€:
    For example, we have a tool with an embedded resource. Can the logic in the resource also be done di...
    • βœ…1
    1 Β· 3 days ago
  • πŸ’ͺAdv. MCP Features
    ⚑General
    Understanding Session and State Management for Remote MCP Server
    Kusten ⚑:
    I just completed the Advanced Features workshop, and the notifications/tools/list_changed section le...
    • βœ…1
    1 Β· a day ago
  • 🐣MCP Fundamentals
    API is deprecated
    thor ⚑:
    I get this error a lot in my terminal (OSX Tahoe 26) . Have to stop / restart the server (npm start)...
    • βœ…1
    2 Β· 4 days ago
  • 🐣MCP Fundamentals
    How is the the first ( and maybe the others too? ) exercise running automatically?
    Kamil ⚑:
    So I just started the course and got to the ping exercise and I am kinda curious how the course app ...
    • βœ…1
    1 Β· 5 days ago
  • ⚑General
    Epic MCP server not initializing
    steve ⚑:
    I am attempting to configure the Epic MCP Server per Kent's instructions here: https://www.epicai.pr...
    • βœ…2
    3 Β· 4 days ago
  • 🐣MCP Fundamentals
    Help getting back to adding my learning notes?
    silvanet πŸš€ 🌌 ⚑:
    When I began, I didn't pay much attention to doing that, but I want to continue by contributing my l...
    • βœ…1
    8 Β· 4 days ago
  • ⚑General
    What will tomorrows MCP hosts look like?
    Paul πŸš€:
    Hi Kent,

Thanks for putting together the course, I’m really enjoying it. Im interested if you have...
    • βœ…1
    2 Β· 5 days ago
  • 🐣MCP Fundamentals
    I'm having a problem error in Prompts 01 lesson?
    silvanet πŸš€ 🌌 ⚑:
    I've checked the code in both the prompt.ts and the index.ts files against the exercise solutions, b...
    • βœ…1
    3 Β· 5 days ago
  • ⚑General
    VS Code Copilot and Epic Workshop MCP Server
    Alexandre πŸš€:
    I might have missed something, but how do we install the Epic Workshop MCP Server so we can ask Copi...
    • βœ…1
    3 Β· 6 days ago
  • 🐣MCP Fundamentals
    Diagram not readable using dark mode
    Alexandre πŸš€:
    The diagram on the Home page is not readable in dark mode
    • βœ…1
    4 Β· 6 days ago
  • 🐣MCP Fundamentals
    What is the difference between tool and registerTool methods?
    lorena πŸš€:
    I have seen tools written in both ways but if tool was declared by server.tool when local mcp server...
    • βœ…1
    4 Β· 11 days ago
  • 🐣MCP Fundamentals
    πŸ’ͺAdv. MCP Features
    πŸ”MCP Auth
    πŸ’»MCP UI
    What about the usage of MCP Servers for some kind of chat interacting with a local LLM?
    frankfullstack ⚑:
    I would like to raise a general question about the usage of MCP Servers and how we could interact fr...
    • βœ…1
    5 Β· 11 days ago
  • 🐣MCP Fundamentals
    Exercise 01/02 (Tools Annotations): OutputSchema
    sachinepicmcp ⚑:
    I see that in exercise 01/02 Tools Annotations, structuredContent is being prepare differently. For ...
    • βœ…1
    3 Β· 7 days ago
  • 🐣MCP Fundamentals
    Workshop login question?
    silvanet πŸš€ 🌌 ⚑:
    I opened my local cloned repo and ran npm start from its local folder /mcp-fundamentals. It responde...
    • βœ…1
    2 Β· 7 days ago
  • 🐣MCP Fundamentals
    Are we going to set up Claude as well as MCP Inspector?
    silvanet πŸš€ 🌌 ⚑:
    Kent referred to Claude in the Resources first solution. I had been checking on my own and saw it re...
    • βœ…1
    1 Β· 7 days ago
  • 🐣MCP Fundamentals
    ⚑General
    It'd be really cool to have a basic deployment guide.
    BeyondLimits99 ⚑:
    The course has been amazing so far! I'd love to have a basic deployment guide just so I can practice...
    • βœ…2
    3 Β· 9 days ago
  • 🐣MCP Fundamentals
    Resource Links in Prompt Messages?
    sachinepicmcp ⚑:
    I am currently working on Exercise 05/02 (Optimized Prompts). It talks about how we can actually als...
    • βœ…1
    1 Β· 11 days ago
  • 🐣MCP Fundamentals
    Deploying MCPs?
    BrianHHough:
    Can you walk through more about the MCP deployment pipeline you mentioned with CloudFlare? Curious w...
    • βœ…1
    3 Β· 12 days ago
  • 🐣MCP Fundamentals
    How does the server run?
    bauti πŸš€ 🌌 ⚑:
    Say for example a web app in local development, we normally have a continuously running server that ...
    • βœ…1
    1 Β· 11 days ago
  • ⚑General
    non-related question: how do you rollout updates?
    mark:
    I'm very curious to hear: How do you roll-out new updates? do you use some kind of libary?
    • βœ…1
    5 Β· 13 days ago
  • 🐣MCP Fundamentals
    Problems running solutions in WSL
    aeldar πŸš€ ⚑:
    Hello! Does anyone managed to run the project app in WSL? I tried to work with the very first exerc...
    • βœ…1
    5 Β· 12 days ago
  • 🐣MCP Fundamentals
    Excercise 3.3 test is failing for me
    Shadab πŸš€ ⚑:
    The test is trying to list resources where URI includes `entries` and since it doesn't find any it i...
    • βœ…1
    6 Β· 11 days ago
  • 🐣MCP Fundamentals
    Errors running setup for MCP Fundamentals:
    silvanet πŸš€ 🌌 ⚑:
    git version 2.47.1.windows.2 node version 22.13.0 npm version 10.9.2 I think I may have located the...
    • βœ…1
    22 Β· 12 days ago
  • 🐣MCP Fundamentals
    Why do we get the zero index entry for resource_link with the count of found results?
    frankfullstack ⚑:
    Hi everyone, I just detected that we get near to the array of results the zero index with some conte...
    • βœ…1
    1 Β· 10 days ago
  • 🐣MCP Fundamentals
    Resource Templates List related question
    frankfullstack ⚑:
    Reading and working with Resource Templates List, I found them a bit similar to HATEOAs in REST APIs...
    • βœ…1
    1 Β· 10 days ago
  • 🐣MCP Fundamentals
    3.2
    nicolai-marina ⚑:
    I am not able to pull data from the db while typing in the UI. Did any of you had this issue?
    • βœ…1
    1 Β· 8 days ago
  • 🐣MCP Fundamentals
    Embedded Resources: CallToolResult
    sachinepicmcp ⚑:
    I am working on 04/01 Embedded Resources (Solution). I am trying to embed resources in all 'tools' m...
    • βœ…1
    1 Β· 11 days ago
  • 🐣MCP Fundamentals
    Test failed: 3.1 Resources: EBUSY: resource busy or locked
    sachinepicmcp ⚑:
    I am getting this error when I run tests for 3.1 Resources exercise. Note, that I am able to play my...
    • βœ…1
    4 Β· 12 days ago
  • 🐣MCP Fundamentals
    ⚑General
    How do you teach the LLMs to use ResourceTemplates and ResourceTemplatesList?
    frontendwizard:
    I'm playing around with building an mcp with claude and he has a tendency to go for json for everyth...
    • βœ…1
    8 Β· 11 days ago
  • 🐣MCP Fundamentals
    Not able to initialize the server
    nicolai-marina ⚑:
    Hello, I am at the first exercise. i am not able to initialize the server.First notification is runn...
    • βœ…1
    2 Β· 11 days ago
  • 🐣MCP Fundamentals
    Vercel AI SDK for MCPs vs the Typescript MCP?
    Fede:
    What's your take on Vercel AI SDK for MCPs vs the Typescript MCP?
    • βœ…1
    4 Β· 12 days ago