Skip to main content
Glama

MCP Server NestJS

by Cstannahill
file.service.ts1.23 kB
// src/file/file.service.ts import { Injectable } from '@nestjs/common'; import { FileBrowserMCP } from '../mcps/file-browser-mcp/file-browser-mcp'; @Injectable() export class FileService { private readonly mcp: FileBrowserMCP; constructor() { // Use S drive as the base path this.mcp = new FileBrowserMCP('s:/'); } async uploadFile(file: Express.Multer.File): Promise<unknown> { // Save file to S drive using MCP return this.mcp.handleRequest('write_file', { path: file.originalname, content: file.buffer.toString('utf8'), overwrite: true, }) as Promise<unknown>; } async getFile(fileId: string): Promise<unknown> { // Read file from S drive using MCP return this.mcp.handleRequest('read_file', { path: fileId, }) as Promise<unknown>; } async deleteFile(fileId: string): Promise<unknown> { // Delete file from S drive using MCP return this.mcp.handleRequest('delete_file', { path: fileId, }) as Promise<unknown>; } async listFiles(): Promise<unknown[]> { const result: unknown = await this.mcp.handleRequest('list_directory', { path: '', }); return result as unknown[]; } // Add other methods as needed }

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/Cstannahill/mcp-server-nestjs'

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