Resource definition with name, description, uri, and read handler
The registered resource (for re-export and type inference)
// resources/config.ts
import { defineResource } from 'mcp-server-framework';
export const configResource = defineResource({
name: 'app-config',
description: 'Application configuration',
uri: 'myapp://config/main',
mimeType: 'application/json',
read: async () => JSON.stringify({
version: '1.0.0',
environment: process.env.NODE_ENV,
}),
});
// resources/readme.ts - Text resource
import { defineResource } from 'mcp-server-framework';
import { readFile } from 'fs/promises';
export const readmeResource = defineResource({
name: 'readme',
description: 'Project README file',
uri: 'myapp://docs/readme',
mimeType: 'text/markdown',
read: async () => readFile('./README.md', 'utf-8'),
});
Define a resource with automatic registration.
This is the recommended way to define static resources in the framework. The resource is automatically registered in the global registry when defined.