Skip to main content
Glama

check_environment

Verify ANTHROPIC_API_KEY configuration and review model details, prior-chapter budget, and Storywright version to ensure environment readiness for multi-agent book writing.

Instructions

Verify ANTHROPIC_API_KEY and show model / prior-chapter budget / Storywright version.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • Core handler function that validates Anthropic API credentials and reports Storywright version, model, and prior-chapter budget settings.
    def check_environment() -> str:
        """Validate Anthropic API env and report Storywright version."""
        msg = api_key_problem_message()
        lines = [
            f"**Storywright** v{__version__}\n",
        ]
        if msg:
            lines.append(f"- API: **NOT READY** — {msg}\n")
        else:
            lines.append(f"- API credentials: {anthropic_auth_mode()}\n")
            bu = os.environ.get("ANTHROPIC_BASE_URL", "").strip()
            if bu:
                lines.append(f"- ANTHROPIC_BASE_URL: `{bu}`\n")
        s = get_settings()
        lines.append(f"- Model: `{s.anthropic_model}`\n")
        lines.append(
            f"- Prior chapter budget: max {s.prior_chapters_max_words} words / "
            f"{s.prior_chapters_max_count} chapters\n"
        )
        return "".join(lines)
  • MCP tool decorator registering 'check_environment' as a FastMCP tool, delegating to workflow.check_environment().
    @mcp.tool()
    async def check_environment() -> str:
        """Verify ANTHROPIC_API_KEY and show model / prior-chapter budget / Storywright version."""
        return workflow.check_environment()
  • Helper that checks for Anthropic API credentials (ANTHROPIC_API_KEY or ANTHROPIC_AUTH_TOKEN) and returns an error message if missing.
    def api_key_problem_message() -> str | None:
        """Return user-facing error if API cannot run.
    
        The Anthropic Python SDK accepts either ``ANTHROPIC_API_KEY`` (``X-Api-Key``) or
        ``ANTHROPIC_AUTH_TOKEN`` (Bearer). MiniMax's Anthropic-compatible gateway matches
        what Claude Code uses with ``ANTHROPIC_AUTH_TOKEN`` + ``ANTHROPIC_BASE_URL``.
        """
        has_key = bool(os.environ.get("ANTHROPIC_API_KEY", "").strip())
        has_bearer = bool(os.environ.get("ANTHROPIC_AUTH_TOKEN", "").strip())
        if not has_key and not has_bearer:
            return (
                "No Anthropic credentials: set ANTHROPIC_API_KEY and/or ANTHROPIC_AUTH_TOKEN "
                "(MiniMax proxy typically uses ANTHROPIC_AUTH_TOKEN + ANTHROPIC_BASE_URL). "
                "Configure MCP `env` in Cursor or a `.env` beside the project."
            )
        return None
  • Helper that returns a human-readable label of which auth mode is configured, used directly in check_environment output.
    def anthropic_auth_mode() -> str:
        """Label for check_environment output."""
        has_key = bool(os.environ.get("ANTHROPIC_API_KEY", "").strip())
        has_bearer = bool(os.environ.get("ANTHROPIC_AUTH_TOKEN", "").strip())
        if has_key and has_bearer:
            return "ANTHROPIC_API_KEY + ANTHROPIC_AUTH_TOKEN"
        if has_bearer:
            return "ANTHROPIC_AUTH_TOKEN (Bearer)"
        return "ANTHROPIC_API_KEY"
  • Settings class (Pydantic) providing the anthropic_model and prior_chapter budget values displayed by check_environment.
    class Settings(BaseSettings):
        model_config = SettingsConfigDict(
            env_prefix="STORYWRIGHT_",
            env_file=".env",
            env_nested_delimiter="__",
            extra="ignore",
        )
    
        # Projects live under `{projects_root}/book_projects/<slug>/`
        projects_root: Path = Path.cwd()
        # Persist last loaded project path here (optional UX)
        state_dir: Path = Path.home() / ".storywright"
        # Model id for writer/editor/third-pass API calls (override per deployment)
        anthropic_model: str = "claude-sonnet-4-20250514"
        # Prior approved prose budget for writer prompts (controls context size)
        prior_chapters_max_words: int = 12000
        prior_chapters_max_count: int = 8
        # Anthropic API transient failures
        anthropic_max_retries: int = 2
        anthropic_retry_delay_seconds: float = 2.0
    
    
    _settings: Settings | None = None
    
    
    def get_settings() -> Settings:
        global _settings
        if _settings is None:
            _settings = Settings()
        return _settings
Behavior2/5

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

No annotations are provided, so the description must cover behavioral traits. It mentions verification and display but lacks details on side effects, permissions, or error conditions (e.g., missing key).

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 extremely concise (one sentence) with no wasted words; every part is necessary.

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

Completeness4/5

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

Given no parameters and an output schema exists, the description is fairly complete for a simple check tool. It mentions all key outputs, though it could add more about behavior when the key is missing.

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

Parameters5/5

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

With zero parameters, the baseline is 4. The description adds clear meaning by specifying what is checked and displayed, going beyond the empty schema.

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: verify ANTHROPIC_API_KEY and show model/budget/version. It uses specific verbs and resources, and it's distinct from sibling tools which are all about book/writing operations.

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 (environment check before other actions) but does not explicitly state when to use vs alternatives or any exclusions.

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/BurgersJackson/storywright-mcp'

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