Advanced Sampling Prompt

👨‍💼 Now that you've wired up basic sampling, it's time to make your prompt have the LLM do something actually useful! Instead of just asking for a generic response, you'll craft a prompt that enables the model to suggest relevant tags for a new journal entry.
Here's what you'll do:
  • Update your sampling request to provide the LLM with structured information: the new journal entry, its current tags, and all existing tags in the system.
  • Change the user message to send this data as JSON (application/json), not plain text.
  • Write a clear, detailed system prompt that instructs the LLM to make a list of suggested tags that are relevant to the entry and not already applied. Make certain it's instructed on the format of the response.
  • Increase the maxTokens to allow for a longer, more detailed response.
  • Test and iterate on your prompt! Try pasting the example JSON into your favorite LLM playground and see how it responds. Refine your instructions until you get the output you want.
Development workflow
🦉 You can use the JSON below to test your prompt:
  1. Write your prompt into the LLM chat
  2. Let it respond (It'll probably ask you to provide the JSON)
  3. Paste the JSON below into the chat and let it respond again
  4. Evaluate the response (make sure it's in the right format)
  5. Repeat in new chats until you're happy with the prompt/response
{
	"entry": {
		"id": 6,
		"title": "Day at the Beach with Family",
		"content": "Spent the whole day at the beach with the family and it couldn't have been better. The kids were totally absorbed in building a massive sandcastle—complete with towers, moats, and even a seaweed flag. We played catch, flew a kite, and waded into the water until our fingers turned into prunes. Rebecca and I went on a shell hunt and found a few keepers. Lunch was sandy PB&Js and watermelon under a big striped umbrella. We stayed until sunset, which painted the sky with ridiculous pinks and oranges. Everyone was sun-tired and happy. Grateful for days like this.",
		"mood": "grateful",
		"location": "beach",
		"weather": "sunny",
		"isPrivate": 0,
		"isFavorite": 1,
		"createdAt": 1746668878,
		"updatedAt": 1746668878,
		"tags": [{ "id": 1, "name": "Family" }]
	},
	"currentTags": [
		{
			"id": 1,
			"name": "Family",
			"description": "Spending time with family members",
			"createdAt": 1746666966,
			"updatedAt": 1746666966
		}
	],
	"existingTags": [
		{
			"id": 1,
			"name": "Family",
			"description": "Spending time with family members",
			"createdAt": 1746666966,
			"updatedAt": 1746666966
		},
		{
			"id": 2,
			"name": "Outdoors",
			"description": "Entries about being outside in nature or open spaces",
			"createdAt": 1746667900,
			"updatedAt": 1746667900
		},
		{
			"id": 3,
			"name": "Exercise",
			"description": "Physical activity or movement",
			"createdAt": 1746668000,
			"updatedAt": 1746668000
		},
		{
			"id": 4,
			"name": "Food",
			"description": "Eating, meals, or anything food-related",
			"createdAt": 1746668001,
			"updatedAt": 1746668001
		}
	]
}
This step will help you practice prompt engineering for structured outputs, and show you how to use the full power of MCP's sampling API for real-world tasks.
There are tests to help verify your sampling request is working.
To test this in the MCP inspector:
  • run the create_entry tool
  • check the "Sampling" navigation tab and you should have a sampling request
  • at this point, YOU are the LLM. You can copy paste this into your response:
{
	"model": "stub-model",
	"stopReason": "endTurn",
	"role": "assistant",
	"content": {
		"type": "text",
		"text": "[{\"id\":2},{\"id\":4},{\"name\":\"Beach\",\"description\":\"Activities or experiences at the beach, including sand, water, and seaside fun\"}]"
	}
}

Please set the playground first

Login to get access to the exclusive discord channel.
  • 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 · a day ago
  • 💪Adv. MCP Features
    Elicitation
    nicolai-marina ⚡:
    After completing the elicitation exercise, I am not able to see the form, which confirms the deletio...
    • 1
    5 · 2 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 · 2 days ago
  • 💪Adv. MCP Features
    console.log(capabilities) in Elicit Confirmation exercise
    Rednar ⚡:
    In the solution video, at second 0:55, there's a console.log(capabilities) and Kent says we'll come ...
    • 1
    3 · 3 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 · 3 days ago
  • 💪Adv. MCP Features
    Resource Templates returning text instead of a schema
    BeyondLimits99 ⚡:
    I was just wondering about the resource templates. I noticed that you're returning the entry schema ...
    • 1
    5 · 3 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 · 9 days ago
  • 💪Adv. MCP Features
    Stateful Server Discussion: Elicitation Exercise and Sampling Exercise
    jbandi:
    I am still trying to wrap my head around the stateful communication model of MCP, which is different...
    • 1
    53 · 6 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 · 6 days ago
  • 💪Adv. MCP Features
    McpServer Instance Lifecycle
    jbandi:
    ​You just said in the q&a of the office hours that the Mcp Server Instance is "long running" like an...
    • 1
    1 · 5 days ago
  • 💪Adv. MCP Features
    Figuring out isOpenWorld when calling ffmpeg or similar
    Kamran ⚡:
    I would love if you wanted to take this into office hours and expand on how you think about isOpenWo...
    • 👍2
    • 1
    1 · 6 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 · 10 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 · 8 days ago
  • 🐣MCP Fundamentals
    General
    MCP to MCP
    Mahendra Hirapra ⚡:
    Does it possible one MCP sever connect to other MCP like chain? I would like to connect Figma MCP Se...
    • 1
    4 · 9 days ago
  • 🐣MCP Fundamentals
    General
    When does an MCP become overkill—that is, when should one avoid building one?
    Lax ⚡:
    Just wondering what scenarios to skip 🙂
    • 1
    2 · 9 days ago
  • 🐣MCP Fundamentals
    General
    💻MCP UI
    🔐MCP Auth
    Are the live sessions, Q&A's or will there be some lectures about concepts around MPC Stack?
    Handax ⚡:
    I’m interested in diving deeper into the Model Contexts Protocol (MCP) and was wondering if there wi...
    • 1
    1 · 9 days ago
  • General
    Lesson lengths
    ffkml ⚡:
    I’m excited for the class to kick off next week. Planning ahead, how long should we plan for lessons...
    • 👍3
    • 1
    1 · 14 days ago