Skip to main content
Glama

mcp_openai_tts

Convert text to speech using OpenAI TTS API. Generates audio files, returns their paths, and ensures users receive the output for further use.

Instructions

OpenAI TTS API를 사용하여 텍스트를 음성으로 변환합니다. 생성된 오디오 파일 경로를 반환하며, 이 경로는 반드시 사용자에게 알려주어야 합니다.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
fileNameNo저장할 파일 이름 (확장자 제외)
modelNo사용할 모델 (예: tts-1, tts-1-hd)
saveDirNo음성 파일을 저장할 디렉토리
speedNo음성 속도(0.25-4.0)
textYes음성으로 변환할 텍스트
voiceNo음성 종류

Implementation Reference

  • Core handler logic for OpenAI TTS: sends POST to /audio/speech endpoint, receives MP3 audio data, saves to file with timestamp, returns JSON with file path and size.
    /**
     * TTS API를 사용하여 텍스트를 음성으로 변환합니다
     */
    async textToSpeech(args: {
      text: string;
      model?: string;
      voice?: string;
      speed?: number;
      saveDir?: string;
      fileName?: string;
    }): Promise<string> {
      try {
        if (!OPENAI_API_KEY) {
          throw new McpError(
            ErrorCode.InternalError,
            'OPENAI_API_KEY가 설정되지 않았습니다.'
          );
        }
    
        const response = await axios.post(
          `${OPENAI_API_BASE}/audio/speech`,
          {
            model: args.model || 'tts-1',
            input: args.text,
            voice: args.voice || 'alloy',  // alloy, echo, fable, onyx, nova, shimmer
            speed: args.speed || 1.0,
            response_format: 'mp3'
          },
          {
            headers: {
              'Content-Type': 'application/json',
              'Authorization': `Bearer ${OPENAI_API_KEY}`
            },
            responseType: 'arraybuffer'
          }
        );
    
        // 음성 파일 저장
        const saveDir = args.saveDir || DEFAULT_SAVE_DIR;
        await this.ensureDirectoryExists(saveDir);
        
        const timestamp = Date.now();
        const fileName = args.fileName ? `${args.fileName}.mp3` : `tts_${timestamp}.mp3`;
        const filePath = path.join(saveDir, fileName);
        
        await writeFileAsync(filePath, Buffer.from(response.data));
    
        return JSON.stringify({
          audio_file: filePath,
          size_bytes: response.data.length,
          message: `음성 파일이 ${filePath}에 저장되었습니다.`
        }, null, 2);
      } catch (error) {
        if (axios.isAxiosError(error)) {
          const statusCode = error.response?.status;
          let errorMessage = error.message;
          
          try {
            // 응답이 arraybuffer일 경우 처리
            if (error.response?.data instanceof ArrayBuffer) {
              const text = Buffer.from(error.response.data).toString('utf8');
              const json = JSON.parse(text);
              errorMessage = json.error?.message || errorMessage;
            }
          } catch (e) {
            // 파싱 오류는 무시
          }
          
          throw new McpError(
            ErrorCode.InternalError,
            `OpenAI API 오류 (${statusCode}): ${errorMessage}`
          );
        }
        
        throw new McpError(ErrorCode.InternalError, `음성 변환 요청 실패: ${formatError(error)}`);
      }
    }
  • MCP tool object definition for 'mcp_openai_tts' with input schema and wrapper handler that calls the OpenAI service and formats ToolResponse.
    {
      name: 'mcp_openai_tts',
      description: 'OpenAI TTS API를 사용하여 텍스트를 음성으로 변환합니다. 생성된 오디오 파일 경로를 반환하며, 이 경로는 반드시 사용자에게 알려주어야 합니다.',
      inputSchema: {
        type: 'object',
        properties: {
          text: {
            type: 'string',
            description: '음성으로 변환할 텍스트'
          },
          model: {
            type: 'string',
            description: '사용할 모델 (예: tts-1, tts-1-hd)'
          },
          voice: {
            type: 'string',
            description: '음성 종류',
            enum: ['alloy', 'echo', 'fable', 'onyx', 'nova', 'shimmer']
          },
          speed: {
            type: 'number',
            description: '음성 속도(0.25-4.0)',
            minimum: 0.25,
            maximum: 4.0
          },
          saveDir: {
            type: 'string',
            description: '음성 파일을 저장할 디렉토리'
          },
          fileName: {
            type: 'string',
            description: '저장할 파일 이름 (확장자 제외)'
          }
        },
        required: ['text']
      },
      async handler(args: any): Promise<ToolResponse> {
        try {
          const result = await openaiService.textToSpeech(args);
          return {
            content: [{
              type: 'text',
              text: result
            }]
          };
        } catch (error) {
          return {
            content: [{
              type: 'text',
              text: `OpenAI TTS 오류: ${error instanceof Error ? error.message : String(error)}`
            }]
          };
        }
      }
    },
  • JSON schema defining input parameters for the mcp_openai_tts tool, requiring 'text' and supporting model, voice, speed, saveDir, fileName.
    inputSchema: {
      type: 'object',
      properties: {
        text: {
          type: 'string',
          description: '음성으로 변환할 텍스트'
        },
        model: {
          type: 'string',
          description: '사용할 모델 (예: tts-1, tts-1-hd)'
        },
        voice: {
          type: 'string',
          description: '음성 종류',
          enum: ['alloy', 'echo', 'fable', 'onyx', 'nova', 'shimmer']
        },
        speed: {
          type: 'number',
          description: '음성 속도(0.25-4.0)',
          minimum: 0.25,
          maximum: 4.0
        },
        saveDir: {
          type: 'string',
          description: '음성 파일을 저장할 디렉토리'
        },
        fileName: {
          type: 'string',
          description: '저장할 파일 이름 (확장자 제외)'
        }
      },
      required: ['text']
    },
  • src/index.ts:25-54 (registration)
    MCP server capabilities registration enabling the mcp_openai_tts tool (set to true).
    tools: {
      mcp_sparql_execute_query: true,
      mcp_sparql_update: true,
      mcp_sparql_list_repositories: true,
      mcp_sparql_list_graphs: true,
      mcp_sparql_get_resource_info: true,
      mcp_ollama_run: true,
      mcp_ollama_show: true,
      mcp_ollama_pull: true,
      mcp_ollama_list: true,
      mcp_ollama_rm: true,
      mcp_ollama_chat_completion: true,
      mcp_ollama_status: true,
      mcp_http_request: true,
      mcp_openai_chat: true,
      mcp_openai_image: true,
      mcp_openai_tts: true,
      mcp_openai_transcribe: true,
      mcp_openai_embedding: true,
      mcp_gemini_generate_text: true,
      mcp_gemini_chat_completion: true,
      mcp_gemini_list_models: true,
      mcp_gemini_generate_images: false,
      mcp_gemini_generate_image: false,
      mcp_gemini_generate_videos: false,
      mcp_gemini_generate_multimodal_content: false,
      mcp_imagen_generate: false,
      mcp_gemini_create_image: false,
      mcp_gemini_edit_image: false
    },
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions that the tool '생성된 오디오 파일 경로를 반환하며, 이 경로는 반드시 사용자에게 알려주어야 합니다' (returns the generated audio file path, which must be communicated to the user), which adds some context about the return value and a user-facing requirement. However, it lacks details on permissions, rate limits, error handling, or whether the operation is read-only or destructive, leaving significant gaps for a tool that creates files.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise and well-structured in two sentences: the first states the tool's purpose, and the second explains the return value and a user requirement. There is no wasted language, and key information is front-loaded, making it efficient and easy to parse.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (6 parameters, file creation) and lack of annotations and output schema, the description is minimally adequate. It covers the basic purpose and return behavior but misses details like error cases, file format, or operational constraints. Without annotations or output schema, more context would be helpful for safe and effective use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all parameters thoroughly. The description does not add any parameter-specific information beyond what the schema provides (e.g., it doesn't explain the significance of 'voice' choices or 'speed' ranges). This meets the baseline of 3, as the schema handles the heavy lifting without additional value from the description.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'OpenAI TTS API를 사용하여 텍스트를 음성으로 변환합니다' (converts text to speech using OpenAI TTS API). It specifies the exact action (convert text to speech) and resource (OpenAI TTS API), and distinguishes itself from sibling tools like chat completion or image generation tools by focusing specifically on text-to-speech conversion.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage context through '텍스트를 음성으로 변환합니다' (converts text to speech), suggesting it should be used when audio output is needed from text. However, it provides no explicit guidance on when to use this tool versus alternatives (e.g., other TTS tools or audio generation methods), nor does it mention any prerequisites or exclusions for usage.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

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/bigdata-coss/agent_mcp'

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