Skip to main content
Glama

create_sample_file

Generate a sample text file for testing purposes with a customizable filename, using the Simple MCP Server's file creation capability.

Instructions

サンプルファイルを作成します(テスト用)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filenameNo作成するファイル名(デフォルト: sample.txt)

Implementation Reference

  • The main handler function for the 'create_sample_file' tool. It creates a sample text file in the current working directory (after path validation) with predefined content including timestamps, system info, and notes.
    private async createSampleFile(filename?: string): Promise<CallToolResult> { const sampleFilename = filename || "sample.txt"; try { // 現在のワーキングディレクトリにサンプルファイルを作成 const fullPath = path.resolve(process.cwd(), sampleFilename); const pathValidation = this.pathValidator.validatePath(fullPath); if (!pathValidation.isValid) { throw new Error(pathValidation.error); } console.error(`Creating sample file: ${pathValidation.normalizedPath}`); const sampleContent = `# サンプルファイル 作成日時: ${new Date().toLocaleString("ja-JP")} これは MCP サーバによって作成されたサンプルファイルです。 ## 内容 - MCP (Model Context Protocol) のテスト - ClaudeDesktop との連携確認 - ファイル操作の動作確認 - セキュリティ制限付きパスアクセス ## システム情報 - Node.js バージョン: ${process.version} - プラットフォーム: ${os.platform()} - アーキテクチャ: ${os.arch()} ## セキュリティ設定 - パスアクセス制限: 有効 - 許可されたディレクトリのみアクセス可能 Happy coding! 🚀 `; await fs.writeFile(pathValidation.normalizedPath, sampleContent, "utf-8"); return { content: [ { type: "text", text: `サンプルファイル "${pathValidation.normalizedPath}" を作成しました!\n\n内容:\n${sampleContent}`, }, ], isError: false, }; } catch (error) { throw new Error(`サンプルファイルの作成に失敗: ${error}`); }
  • src/index.ts:169-181 (registration)
    Tool registration in the TOOLS array, including name, description, and input schema. This is returned by the ListTools handler.
    { name: "create_sample_file", description: "サンプルファイルを作成します(テスト用)", inputSchema: { type: "object", properties: { filename: { type: "string", description: "作成するファイル名(デフォルト: sample.txt)", }, }, }, },
  • Input schema definition for the 'create_sample_file' tool, specifying an optional 'filename' parameter.
    inputSchema: { type: "object", properties: { filename: { type: "string", description: "作成するファイル名(デフォルト: sample.txt)", }, }, },
  • Dispatch case in the main CallToolRequestSchema handler that routes to the createSampleFile method.
    case "create_sample_file": return await this.createSampleFile(args.filename as string);

Latest Blog Posts

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/p-united/mcpSample'

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