Skip to main content
Glama

run_gemini

Execute prompts using Gemini AI to analyze files, directories, or URLs while conserving Claude Code tokens through efficient context management.

Instructions

Gemini를 사용하여 프롬프트를 실행합니다.

Args:
    prompt: Gemini에 전달할 프롬프트
    file_dir_url_path: 분석할 파일, 디렉토리 또는 URL 경로
    working_directory: 작업 디렉토리 (필수)

Returns:
    dict: 실행 결과 또는 에러 메시지

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
promptYes
file_dir_url_pathYes
working_directoryYes

Implementation Reference

  • The handler function for the MCP tool 'run_gemini'. It runs the Gemini CLI tool with the given prompt augmented with file_dir_url_path, in the specified working_directory, handling errors and timeouts. Registered via @mcp.tool() decorator, which also defines the input schema via type hints and docstring.
    @mcp.tool()
    def run_gemini(prompt: str, file_dir_url_path: str, working_directory: str) -> dict:
        """
        Gemini를 사용하여 프롬프트를 실행합니다.
    
        Args:
            prompt: Gemini에 전달할 프롬프트
            file_dir_url_path: 분석할 파일, 디렉토리 또는 URL 경로
            working_directory: 작업 디렉토리 (필수)
    
        Returns:
            dict: 실행 결과 또는 에러 메시지
        """
    
        prompt = prompt + f" (분석할 파일, 디렉토리 또는 URL 경로: {file_dir_url_path})"
        
        # 현재 디렉토리 저장
        original_cwd = os.getcwd()
        
        try:
            # 작업 디렉토리로 변경
            os.chdir(working_directory)
            
            # Gemini 명령 실행
            cmd = [
                "gemini",
                "-m", "gemini-2.5-flash",
                "-p", prompt
            ]
    
            # shell=True로 실행 (MCP 서버 환경에서 필수)
            shell_cmd = ' '.join(
                [f'"{arg}"' if ' ' in arg else arg for arg in cmd])
    
            result = subprocess.run(
                shell_cmd,
                shell=True,  # 필수
                capture_output=True,
                text=True,
                timeout=360,
                stdin=subprocess.DEVNULL
            )
    
            # 에러 체크
            if result.returncode != 0:
                return {"error": f"Gemini 실행 오류: {result.stderr}"}
    
            # 결과 반환
            return {"result": result.stdout.strip()}
    
        except subprocess.TimeoutExpired:
            return {"error": "Gemini 실행 시간 초과 (360초)"}
        except FileNotFoundError:
            return {"error": "Gemini CLI가 설치되어 있지 않습니다. 'gemini' 명령을 사용할 수 있는지 확인하세요."}
        except Exception as e:
            return {"error": f"실행 중 오류 발생: {str(e)}"}
        finally:
            # 원래 디렉토리로 복원
            os.chdir(original_cwd)
Behavior2/5

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

No annotations are provided, so the description carries full burden. It mentions '실행 결과 또는 에러 메시지' (execution result or error message), hinting at possible errors, but lacks details on behavioral traits like rate limits, authentication needs, or what 'run' entails (e.g., is it destructive, async, etc.). This is inadequate for a tool with no annotation coverage.

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

Conciseness4/5

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

The description is appropriately sized and front-loaded: it starts with the core purpose, then lists args and returns in a structured format. Every sentence adds value, with no wasted words, though it could be slightly more polished.

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 3 parameters with 0% schema coverage and no output schema, the description provides basic purpose and parameter semantics but lacks details on behavior, usage context, and output format. It's minimally viable but has clear gaps in completeness for a tool that executes prompts with external resources.

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

Parameters4/5

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

Schema description coverage is 0%, so the description must compensate. It adds meaning by explaining each parameter: 'prompt' is for Gemini input, 'file_dir_url_path' is for analysis targets, and 'working_directory' is required for operations. This clarifies semantics beyond the bare schema, though it could be more detailed.

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

Purpose4/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: 'Gemini를 사용하여 프롬프트를 실행합니다' (Run a prompt using Gemini). It specifies the verb ('run') and resource ('prompt with Gemini'), but without sibling tools, it cannot distinguish from alternatives. The purpose is clear but lacks differentiation context.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. It lists parameters but offers no context about appropriate scenarios, prerequisites, or exclusions. Without sibling tools, this is less critical, but still a gap in usage context.

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

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/InfolabAI/gemini-cli-mcp'

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