Producto
Integración con clientes MCP
PromptFlowEngine habla el Model Context Protocol, así que cualquier cliente MCP (el modo agente de GitHub Copilot, Claude Desktop, Claude Code, Cursor o tu propio agente) puede llamar al motor como herramientas. Así, tu asistente puede revisar, reestructurar y sanear un prompt como un paso de su propio trabajo, en lugar de hacerlo tú a mano.
@promptflow/mcp-server v2.1.0, nombre del servidor promptflow-engine). Tu herramienta de IA es el cliente MCP que se conecta a él.Configuración para Claude Code, Windsurf y Gemini CLI, un ejemplo de cliente TypeScript y solución de problemas: Conectar PromptFlowEngine.
Cómo se conecta
MCP client (Copilot, Claude, Cursor, your agent)
│ spawns a local process and talks JSON-RPC over stdio
▼
promptflow-mcp (node packages/mcp-server/dist/bin.js)
│ validates arguments, runs the engine in-process
▼
@promptflow/engine no network, no model calls, no files readEl transporte es solo stdio. El servidor se ejecuta en tu equipo como proceso hijo del cliente, solo lee los argumentos que recibe y no hace llamadas de red.
Autenticación
No hace falta ni se admite: no hay clave API, cuenta ni token. El acceso lo controla tu sistema operativo, ya que solo un proceso que tú inicias puede hablar con el servidor por su entrada y salida estándar. No hay endpoint MCP alojado ni por HTTP; para uso remoto, llama a la API HTTP.
Configuración
Compílalo desde una copia del repositorio de PromptFlowEngine (la publicación en npm está pendiente) y apunta tu cliente a dist/bin.js:
pnpm --filter @promptflow/engine build && pnpm --filter @promptflow/mcp-server build{
"servers": {
"promptflow": {
"type": "stdio",
"command": "node",
"args": ["/absolute/path/to/checkout/packages/mcp-server/dist/bin.js"]
}
}
}{
"mcpServers": {
"promptflow": { "command": "node", "args": ["/absolute/path/to/checkout/packages/mcp-server/dist/bin.js"] }
}
}La extensión de VS Code incluye el mismo servidor y escribe la primera entrada por ti.
| Variable de entorno | Valor por defecto | Finalidad |
|---|---|---|
PROMPTFLOW_MCP_MAX_PROMPT_CHARS | 100000 | Máximo de caracteres por argumento de texto (límite absoluto 2.000.000). |
PROMPTFLOW_MCP_LOG | sin definir | debug registra en stderr el nombre de la herramienta, el tamaño de la entrada, el resultado y la duración. Nunca el contenido. |
Capacidades: herramientas (19)
| Herramienta | Descripción |
|---|---|
optimize_prompt | Optimize a prompt with deterministic, verified transforms (duplicates, filler, optional sections). Every candidate is checked to preserve all sentences, requirements, code, and variables; the original is kept if nothing is better. Returns the selected prompt, token savings, quality score, and what changed. |
optimize_prompt_pipeline | Run the optimization pipeline and return per-stage results plus token and estimated cost metrics, in the result shape used by the PromptFlow VS Code extension. |
compress_prompt | Remove exact duplicate sentences and extra whitespace without rewriting any wording. |
validate_prompt | Check a prompt for missing objective or output format, ambiguity, conflicting instructions, duplicates, prompt-injection patterns, secrets, and undelimited variables. isValid is false only when a critical issue exists. |
estimate_tokens | Count tokens and estimate input cost for a model. "exact" is true only for OpenAI models with a loaded tokenizer; other providers are approximate. Costs are estimates from a reference price table. |
analyze_prompt | Detect intent, task type, technical domain, requested output, requirements, and entities (languages, frameworks, file paths, identifiers). |
extract_entities | Extract languages, frameworks, libraries, cloud platforms, services, technologies, file paths, identifiers, URLs, and commands. |
summarize_context | Extractive summary: the first N unique, non-empty sentences of a context block, in order. Does not rank or rewrite. |
score_prompt | Score prompt quality 0-100: 100 minus a penalty per issue (critical 30, warning 10, info 3; capped at 50 with any critical issue), with per-dimension scores and suggestions. |
evaluate_prompt | Full quality report: overall score, grade, eight quality dimensions with the checks that failed, and every finding with why it matters and how to fix it. |
compare_prompts | Compare two prompts: token and estimated cost delta, quality delta per dimension, and which findings were resolved or introduced. |
scan_prompt_security | Prompt-injection risk (0-100, signature-based, with threat ids), sensitive-data counts by category, undelimited template variables, and destructive operations. Never returns detected secret values. |
scan_sensitive_data | Scan text for credentials, cloud secrets, and PII with local deterministic detectors. Returns offsets and per-category counts, never the sensitive values. |
sanitize_prompt | Replace detected sensitive data with placeholders such as [REDACTED_API_KEY]. Returns the sanitized text and counts, never the original values. Use before sending a prompt to an external model. |
restructure_prompt | Turn a loosely written request into a sectioned engineering prompt: Role, Objective, Context, Requirements, Constraints, Edge cases, Testing, Acceptance criteria, Expected output. Only sections with content appear. The author's clauses are kept and reordered; for software tasks, fixed engineering guidance chosen by intent and topic is added, and every line is labeled "prompt" or "engine" so additions can be reviewed. Set scaffold=false to reorganize without adding guidance. |
convert_structured_payload | Convert a JSON payload to TOON (Token-Oriented Object Notation) and say whether to use it. Returns token counts for pretty JSON, compact JSON and TOON, a round-trip check (the TOON must decode back to the same value), and the recommendation: "toon" only when it round-trips and saves at least 5 % over compact JSON, otherwise "json". Lossless or it keeps JSON. |
simulate_cost | Simulate what a prompt costs across models at a request volume, from catalog list prices (labelled simulated, never a bill). Optionally optimizes the prompt first and reports hypothetical savings. Flags models whose context window is too small. |
analyze_context_budget | Measure the context sources you intend to send with a prompt: tokens and share per source, context-window usage with an output reserve, sensitive data (categories and counts only), instruction-like text in retrieved sources, and duplicates. Reads only the text passed in; never reads files. |
run_prompt_tests | Run a regression suite against a prompt. Assertions check the prompt (contains, not_contains, matches, max_tokens, min_quality, no_finding, max_severity, has_variables, max_injection_risk, no_sensitive_data, output_format) and, when a case carries a recorded model response, the response (response_valid_json, response_has_keys, response_contains, response_max_chars). With baseline_prompt, also runs the suite on the baseline and lists cases that regressed. No model is called. |
Todas las herramientas están anotadas como de solo lectura e idempotentes. Las once primeras mantienen exactamente los campos de resultado que tenían en la extensión 1.5.x, así que las configuraciones de agentes existentes siguen funcionando.
Recursos y prompts
promptflow://rules: el catálogo de reglas, las dimensiones y las penalizaciones de puntuación.promptflow://models: modelos, codificaciones de tokens y precios de referencia.- Prompt
review-prompt: pide al asistente que evalúe y optimice un prompt, con el prompt envuelto en etiquetas como datos.
Ejemplo
En un chat con un agente, pídelo con lenguaje normal y el cliente elige la herramienta:
Use promptflow to restructure this before you start:
"fix login issue and make google login work and don't break anything"{
"name": "restructure_prompt",
"arguments": { "prompt": "fix login issue and make google login work and don't break anything" }
}{
"restructuredPrompt": "## Role\nAct as a senior software engineer.\n\n## Objective\nFix login issue and make Google login work.\n…",
"intent": "debugging",
"topics": ["authentication"],
"counts": { "prompt": 4, "engine": 20, "codebase": 0 }
}Para probarlo sin cliente, envía JSON-RPC al proceso por una tubería:
printf '%s\n' \
'{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-06-18","capabilities":{},"clientInfo":{"name":"cli","version":"1"}}}' \
'{"jsonrpc":"2.0","method":"notifications/initialized"}' \
'{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"estimate_tokens","arguments":{"prompt":"Hello, world!","model":"gpt-4o"}}}' \
| node packages/mcp-server/dist/bin.jsErrores y seguridad
- Los argumentos se validan con un esquema. Los argumentos incorrectos o demasiado grandes devuelven un error de herramienta (
isError) con el motivo, no un error de protocolo, para que los agentes puedan corregir y reintentar. - Ninguna herramienta devuelve los valores secretos detectados: los resultados de datos sensibles solo llevan categorías y posiciones.
- El texto de prompt que se pasa a una herramienta se trata como datos. El servidor nunca lo ejecuta, y la plantilla
review-promptlo envuelve en etiquetas para el modelo. - El servidor no tiene herramientas de archivos, shell ni red, así que un agente con un prompt inyectado no puede usarlo para llegar a nada.