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:
Anton Pidkuiko 2025-12-15 19:09:47 +07:00 • committed by GitHub
commit 8550545ccb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 31 additions and 20 deletions

View file

@ -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();

View file

@ -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");

View file

@ -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");

View file

@ -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"),

View file

@ -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"),

View file

@ -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"),

View file

@ -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"),

View file

@ -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"),

View file

@ -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"),

View file

@ -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"),