Skip to main content
Glama

mcp-pyodide

by yonaka15
index.ts1.24 kB
import { Resource, ResourceContents } from "@modelcontextprotocol/sdk/types.js"; import { PyodideManager } from "../lib/pyodide/pyodide-manager.js"; import * as path from "path"; export class ResourceClient { constructor(private pyodideManager: PyodideManager) {} async listResources(): Promise<Resource[]> { const resources = await this.pyodideManager.listResources(); return resources.map((resource) => { return { uri: resource.uri, name: resource.name, mimeType: resource.mimeType, }; }); } async readResource(uri: string): Promise<Resource> { const mountPointInfo = this.pyodideManager.getMountPointInfo(uri); if (!mountPointInfo) { throw new Error("Invalid URI"); } // Get each value from pathInfo const { mountName, relativePath } = mountPointInfo; const result = await this.pyodideManager.readResource( mountName, relativePath ); // Check for error if ("error" in result) { throw new Error(result.error); } // Get filename for the resource name const name = path.basename(relativePath); return { uri, name, blob: result.blob, mimeType: result.mimeType, }; } }

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/yonaka15/mcp-pyodide'

If you have feedback or need assistance with the MCP directory API, please join our Discord server