fix: add mimeType to resource declarations in examples (#149)
According to spec, mimeType should be present in both the resource declaration and the resource content. This adds the missing mimeType to the registerResource() declaration (third parameter) in all example servers and the quickstart documentation. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: ochafik <olivier.chafik@gmail.com>
This commit is contained in:
parent
372c24181e
commit
8550545ccb
10 changed files with 31 additions and 20 deletions
|
|
@ -130,17 +130,22 @@ server.registerTool(
|
|||
},
|
||||
);
|
||||
|
||||
server.registerResource(resourceUri, resourceUri, {}, async () => {
|
||||
const html = await fs.readFile(
|
||||
path.join(import.meta.dirname, "dist", "mcp-app.html"),
|
||||
"utf-8",
|
||||
);
|
||||
return {
|
||||
contents: [
|
||||
{ uri: resourceUri, mimeType: "text/html;profile=mcp-app", text: html },
|
||||
],
|
||||
};
|
||||
});
|
||||
server.registerResource(
|
||||
resourceUri,
|
||||
resourceUri,
|
||||
{ mimeType: "text/html;profile=mcp-app" },
|
||||
async () => {
|
||||
const html = await fs.readFile(
|
||||
path.join(import.meta.dirname, "dist", "mcp-app.html"),
|
||||
"utf-8",
|
||||
);
|
||||
return {
|
||||
contents: [
|
||||
{ uri: resourceUri, mimeType: "text/html;profile=mcp-app", text: html },
|
||||
],
|
||||
};
|
||||
},
|
||||
);
|
||||
|
||||
// Express server for MCP endpoint
|
||||
const app = express();
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ function createServer(): McpServer {
|
|||
server.registerResource(
|
||||
RESOURCE_URI,
|
||||
RESOURCE_URI,
|
||||
{},
|
||||
{ mimeType: RESOURCE_MIME_TYPE },
|
||||
async (): Promise<ReadResourceResult> => {
|
||||
const html = await fs.readFile(path.join(DIST_DIR, "mcp-app.html"), "utf-8");
|
||||
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ function createServer(): McpServer {
|
|||
server.registerResource(
|
||||
RESOURCE_URI,
|
||||
RESOURCE_URI,
|
||||
{},
|
||||
{ mimeType: RESOURCE_MIME_TYPE },
|
||||
async (): Promise<ReadResourceResult> => {
|
||||
const html = await fs.readFile(path.join(DIST_DIR, "mcp-app.html"), "utf-8");
|
||||
|
||||
|
|
|
|||
|
|
@ -280,7 +280,10 @@ function createServer(): McpServer {
|
|||
server.registerResource(
|
||||
resourceUri,
|
||||
resourceUri,
|
||||
{ description: "Interactive Budget Allocator UI" },
|
||||
{
|
||||
mimeType: RESOURCE_MIME_TYPE,
|
||||
description: "Interactive Budget Allocator UI",
|
||||
},
|
||||
async (): Promise<ReadResourceResult> => {
|
||||
const html = await fs.readFile(
|
||||
path.join(DIST_DIR, "mcp-app.html"),
|
||||
|
|
|
|||
|
|
@ -182,7 +182,7 @@ function createServer(): McpServer {
|
|||
server.registerResource(
|
||||
resourceUri,
|
||||
resourceUri,
|
||||
{},
|
||||
{ mimeType: RESOURCE_MIME_TYPE },
|
||||
async (): Promise<ReadResourceResult> => {
|
||||
const html = await fs.readFile(
|
||||
path.join(DIST_DIR, "mcp-app.html"),
|
||||
|
|
|
|||
|
|
@ -86,7 +86,10 @@ function createServer(): McpServer {
|
|||
server.registerResource(
|
||||
resourceUri,
|
||||
resourceUri,
|
||||
{ description: "Customer Segmentation Explorer UI" },
|
||||
{
|
||||
mimeType: RESOURCE_MIME_TYPE,
|
||||
description: "Customer Segmentation Explorer UI",
|
||||
},
|
||||
async (): Promise<ReadResourceResult> => {
|
||||
const html = await fs.readFile(
|
||||
path.join(DIST_DIR, "mcp-app.html"),
|
||||
|
|
|
|||
|
|
@ -291,7 +291,7 @@ function createServer(): McpServer {
|
|||
server.registerResource(
|
||||
resourceUri,
|
||||
resourceUri,
|
||||
{ description: "SaaS Scenario Modeler UI" },
|
||||
{ mimeType: RESOURCE_MIME_TYPE, description: "SaaS Scenario Modeler UI" },
|
||||
async (): Promise<ReadResourceResult> => {
|
||||
const html = await fs.readFile(
|
||||
path.join(DIST_DIR, "mcp-app.html"),
|
||||
|
|
|
|||
|
|
@ -152,7 +152,7 @@ function createServer(): McpServer {
|
|||
server.registerResource(
|
||||
resourceUri,
|
||||
resourceUri,
|
||||
{ description: "System Monitor UI" },
|
||||
{ mimeType: RESOURCE_MIME_TYPE, description: "System Monitor UI" },
|
||||
async (): Promise<ReadResourceResult> => {
|
||||
const html = await fs.readFile(
|
||||
path.join(DIST_DIR, "mcp-app.html"),
|
||||
|
|
|
|||
|
|
@ -194,7 +194,7 @@ function createServer(): McpServer {
|
|||
server.registerResource(
|
||||
resourceUri,
|
||||
resourceUri,
|
||||
{ description: "Three.js Widget UI" },
|
||||
{ mimeType: RESOURCE_MIME_TYPE, description: "Three.js Widget UI" },
|
||||
async (): Promise<ReadResourceResult> => {
|
||||
const html = await fs.readFile(
|
||||
path.join(DIST_DIR, "mcp-app.html"),
|
||||
|
|
|
|||
|
|
@ -127,7 +127,7 @@ function createServer(): McpServer {
|
|||
server.registerResource(
|
||||
resourceUri,
|
||||
resourceUri,
|
||||
{},
|
||||
{ mimeType: RESOURCE_MIME_TYPE },
|
||||
async (): Promise<ReadResourceResult> => {
|
||||
const html = await fs.readFile(
|
||||
path.join(DIST_DIR, "mcp-app.html"),
|
||||
|
|
|
|||
Loading…
Reference in a new issue