/**
* Server Resources
*
* Resources that expose server and user information.
*/
import type { ResourceDefinition } from './types';
/**
* Server info resource
* Exposes metadata about the server and current session
*/
export const serverInfoResource: ResourceDefinition = {
name: 'server_info',
uri: 'mcp://my-mcp/info',
description: 'Server configuration and current session info',
mimeType: 'application/json',
handler: async (uri, context) => ({
contents: [{
uri: uri.href,
mimeType: 'application/json',
text: JSON.stringify({
name: context?.serverName ?? 'my-mcp-server',
version: context?.serverVersion ?? '1.0.0',
user: context?.props?.email ?? 'not authenticated',
capabilities: ['tools', 'resources', 'prompts'],
tools_count: context?.toolsCount ?? 0,
}, null, 2),
}],
}),
};
/**
* User profile resource (requires auth)
* Exposes the authenticated user's profile
*/
export const userProfileResource: ResourceDefinition = {
name: 'user_profile',
uri: 'mcp://my-mcp/user',
description: 'Current authenticated user profile',
mimeType: 'application/json',
handler: async (uri, context) => {
if (!context?.props) {
return {
contents: [{
uri: uri.href,
mimeType: 'text/plain',
text: 'Not authenticated',
}],
};
}
return {
contents: [{
uri: uri.href,
mimeType: 'application/json',
text: JSON.stringify({
id: context.props.id,
email: context.props.email,
name: context.props.name,
picture: context.props.picture,
}, null, 2),
}],
};
},
};
/**
* All server resources
*/
export const serverResources: ResourceDefinition[] = [
serverInfoResource,
userProfileResource,
];