Skip to content

Provide INSTRUCTIONS.md as an MCP resource.#12

Merged
ForLoopCodes merged 1 commit intoForLoopCodes:mainfrom
eamsden:instruction-resource
Mar 3, 2026
Merged

Provide INSTRUCTIONS.md as an MCP resource.#12
ForLoopCodes merged 1 commit intoForLoopCodes:mainfrom
eamsden:instruction-resource

Conversation

@eamsden
Copy link
Copy Markdown
Contributor

@eamsden eamsden commented Mar 3, 2026

Pasting INSTRUCTIONS.md into shared projects might be unwelcome clutter. Providing it as an MCP resource that user-configured agent preferences can refer to helps with this.

Pasting INSTRUCTIONS.md into shared projects might be unwelcome clutter.
Providing it as an MCP resource that user-configured agent preferences
can refer to helps with this.
@vercel
Copy link
Copy Markdown

vercel Bot commented Mar 3, 2026

@eamsden is attempting to deploy a commit to the ForLoopCodes' projects Team on Vercel.

A member of the Team first needs to authorize it.

@ForLoopCodes ForLoopCodes marked this pull request as ready for review March 3, 2026 20:23
Copilot AI review requested due to automatic review settings March 3, 2026 20:23
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an MCP resource that serves the repository’s INSTRUCTIONS.md, allowing agent preferences to reference the instructions without copying the file into user projects.

Changes:

  • Introduces constants for the on-disk INSTRUCTIONS.md location and a stable resource URI.
  • Registers a new MCP resource (contextplus_instructions) that returns INSTRUCTIONS.md as text/markdown.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/index.ts
Comment on lines +142 to +148
async (uri) => ({
contents: [{
uri: uri.href,
mimeType: "text/markdown",
text: await readFile(INSTRUCTIONS_PATH, "utf8"),
}],
}),
Copy link

Copilot AI Mar 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The resource handler directly awaits readFile(INSTRUCTIONS_PATH). If INSTRUCTIONS.md is missing from the installed package (or the path resolution changes), this will throw and may fail the resource request (and possibly bubble up as a server error). Consider catching readFile errors here and returning a clear, deterministic message (or fallback content) rather than letting the exception propagate.

Suggested change
async (uri) => ({
contents: [{
uri: uri.href,
mimeType: "text/markdown",
text: await readFile(INSTRUCTIONS_PATH, "utf8"),
}],
}),
async (uri) => {
let text: string;
try {
text = await readFile(INSTRUCTIONS_PATH, "utf8");
} catch (error) {
text =
"# Context+ Instructions\n\n" +
"The instructions file could not be loaded from the expected location.\n\n" +
`Expected path: \`${INSTRUCTIONS_PATH}\`.\n\n` +
"This may indicate a packaging or installation issue. Please ensure that the `INSTRUCTIONS.md` file " +
"is included in the installed package and that the path resolution is correct.";
}
return {
contents: [
{
uri: uri.href,
mimeType: "text/markdown",
text,
},
],
};
},

Copilot uses AI. Check for mistakes.
Comment thread src/index.ts
Comment on lines +139 to +147
server.resource(
"contextplus_instructions",
INSTRUCTIONS_RESOURCE_URI,
async (uri) => ({
contents: [{
uri: uri.href,
mimeType: "text/markdown",
text: await readFile(INSTRUCTIONS_PATH, "utf8"),
}],
Copy link

Copilot AI Mar 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This reads INSTRUCTIONS.md from disk on every resource request. Since the content is static, consider reading it once at startup (or memoizing it) to avoid repeated filesystem I/O and simplify failure handling (single place to report missing file).

Copilot uses AI. Check for mistakes.
@ForLoopCodes ForLoopCodes merged commit 121231b into ForLoopCodes:main Mar 3, 2026
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants