Skip to main content
Glama
Ivan-Madera

midd-nestjs-hexagonal-architecture-mcp

by Ivan-Madera

add_authorization

Adds opt-in HTTP-edge authorization to a NestJS service: an IAuthorizationVerifier port, default API adapter, and a global secure-by-default, fail-closed guard (403).

Instructions

OPT-IN. Agrega la autorización del borde HTTP al servicio: puerto agnóstico IAuthorizationVerifier + adapter por defecto (API de autorización) + Guard GLOBAL, secure-by-default (todo endpoint protegido salvo @SkipAuthorization()) y FAIL-CLOSED (denegado o autorizador inalcanzable = 403). El agente DEBE PREGUNTAR al usuario si quiere activarla; nunca decide solo ni la omite en silencio. Se crea UNA vez por servicio en src/shared/authorization. Parchea ConfigurationVariables, el schema Joi, .env.example y app.module (la registra DESPUÉS de SecurityModule para que el rate limit corra primero). Idempotente.

Input Schema

NameRequiredDescriptionDefault
overwriteNoSi true, sobrescribe archivos existentes. Por defecto false (no pisa).
projectRootYesRuta absoluta de la raíz del servicio NestJS destino donde se escriben los archivos.
authorizationApiUrlNoSample base URL of the authorization API for .env.example. Use a placeholder: the real value goes in the untracked .env.https://authorization.example.com/authorization/v1

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4.4/5.0
Behavior5/5

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

With no annotations, the description carries the full burden and does so thoroughly: secure-by-default with @SkipAuthorization() escape hatch, fail-closed semantics (403 on denial or unreachable authorizer), registration order after SecurityModule so rate limiting runs first, the files it patches, and idempotency.

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?

Dense but front-loaded with 'OPT-IN.' and the mandatory-ask rule, which are the highest-stakes facts. Every clause carries information (fail-closed, module ordering, patched files), though the single long sentence-per-idea style is harder to scan than it could be.

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

Completeness5/5

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

For a side-effectful scaffolding tool with no annotations and no output schema, the description covers what changes, what is created, security behavior, ordering constraints, and idempotency—everything an agent needs to call it correctly and warn the user.

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 coverage is 100%, so all three parameters are already documented in the schema. The description adds context about file patching and overwrite/idempotent behavior but does not explain the individual parameters beyond what the schema provides, making the baseline 3 appropriate.

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?

States a specific verb and resource ('Agrega la autorización del borde HTTP al servicio') and enumerates the concrete artifacts created (IAuthorizationVerifier port, default adapter, GLOBAL Guard). This is clearly distinguishable from siblings like scaffold_service or add_use_case.

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

Usage Guidelines4/5

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

Explicit when-to-use context: OPT-IN, agent must ask the user, never decide alone or silently omit, created once per service, idempotent. It does not name alternative tools for related security concerns, which keeps it below a 5, but the usage conditions are unusually clear.

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