[ ABORT TO HUD ]
SEQ. 1
SEQ. 2
SEQ. 3

Context Assembly

Prompts8 min90 BASE XP

Injecting Resources into Prompts

The ultimate power of an MCP Prompt is assembling vast amounts of context before the conversation even starts. Inside your prompt function, you can load external Resource data.

server.prompt(
  "onboard_developer",
  {},
  async () => {
    // Dynamically assemble context
    const architecture = await fs.readFile('architecture.md');
    return {
      messages: [{
        role: "user",
        content: {
          type: "text",
          text: `Here is the team architecture: ${architecture}\n\nPlease explain the build process.`
        }
      }]
    };
  }
);

This pattern ensures the LLM is perfectly grounded with absolute truth before the user asks their first question.

SYNAPSE VERIFICATION
QUERY 1 // 3
Why might you read files dynamically inside a Prompt function?
To validate the file system.
To inject massive blocks of accurate, up-to-date context into the LLM prompt.
To compress network traffic.
You cannot read files in a Prompt function.
Watch: 139x Rust Speedup
Context Assembly | Prompts — MCP Academy