-
Notifications
You must be signed in to change notification settings - Fork 30
STDIO connection support improvements #2167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
vibegui
wants to merge
1
commit into
main
Choose a base branch
from
feat/stdio-connection-support
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 73 additions & 10 deletions
83
apps/docs/client/src/content/pt-br/mcp-mesh/mcp-servers.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,27 +1,90 @@ | ||
| --- | ||
| title: Conexões | ||
| description: Conexões com MCP servers upstream (HTTP) que o Mesh faz proxy e observa | ||
| description: Conexões com MCPs upstream que o Mesh faz proxy e observa | ||
| icon: Server | ||
| --- | ||
|
|
||
| ## O que é uma Conexão (no Mesh)? | ||
| import Callout from "../../../components/ui/Callout.astro"; | ||
|
|
||
| No Mesh, uma **Conexão** é uma **connection** para um MCP upstream (normalmente um endpoint MCP via HTTP). | ||
| ## O que é uma conexão? | ||
|
|
||
| Cada connection guarda: | ||
| No Mesh, uma **Conexão** é a configuração de um MCP upstream. | ||
|
|
||
| - **URL do MCP** | ||
| Cada conexão guarda: | ||
|
|
||
| - **URL do MCP** (para HTTP) ou **comando** (para STDIO) | ||
| - **credenciais/config** (quando necessário, armazenadas no vault) | ||
| - metadados para operação (nome, status, etc.) | ||
|
|
||
| ## Quando usar vs Agent | ||
| ## Tipos de Conexão | ||
|
|
||
| ### Conexões HTTP | ||
|
|
||
| Conexões HTTP conectam a servidores MCP remotos via endpoints HTTP/SSE. | ||
|
|
||
| - **Casos de uso**: MCPs em nuvem, integrações SaaS, produção | ||
| - **Tokens**: JWT com expiração curta (5 minutos) | ||
|
|
||
| ### Conexões STDIO (Comandos Locais) | ||
|
|
||
| Conexões STDIO iniciam um processo local (como `npx` ou scripts) e comunicam via stdin/stdout. | ||
|
|
||
| - **Casos de uso**: Ferramentas locais, pacotes npx, desenvolvimento | ||
| - **Tokens**: JWT sem expiração, persistido localmente | ||
|
|
||
| <Callout type="tip"> | ||
| Conexões STDIO são perfeitas para rodar pacotes npm como MCPs. Exemplo: `npx @decocms/local-fs` roda um MCP de sistema de arquivos localmente. | ||
| </Callout> | ||
|
|
||
| ## Credenciais STDIO via Variáveis de Ambiente | ||
|
|
||
| Quando o mesh inicia um processo MCP STDIO, ele passa credenciais como variáveis de ambiente: | ||
|
|
||
| | Variável | Descrição | | ||
| |----------|-----------| | ||
| | `MESH_TOKEN` | Token JWT para autenticação com a API do Mesh (sem expiração) | | ||
| | `MESH_URL` | URL base da instância Mesh | | ||
| | `MESH_STATE` | Estado com valores de bindings em JSON | | ||
|
|
||
| Isso é análogo a como conexões HTTP recebem headers `x-mesh-token`. | ||
|
|
||
| - Use **connection** para isolar e depurar um upstream específico. | ||
| <Callout type="tip"> | ||
| **Nenhuma ferramenta especial necessária!** Apenas leia `process.env.MESH_TOKEN` na inicialização. Não precisa implementar `ON_MCP_CONFIGURATION` ou qualquer protocolo de configuração. | ||
| </Callout> | ||
|
|
||
| ### Exemplo (Node.js/Bun) | ||
|
|
||
| ```typescript | ||
| // Ler credenciais mesh das env vars | ||
| const meshToken = process.env.MESH_TOKEN; | ||
| const meshUrl = process.env.MESH_URL; | ||
| const state = process.env.MESH_STATE ? JSON.parse(process.env.MESH_STATE) : {}; | ||
|
|
||
| // ID da Conexão (você pega na UI em Connections, ou via API) | ||
| const connectionId = "<connection-id>"; | ||
|
|
||
| // Usar token para chamadas à API mesh | ||
| const response = await fetch(`${meshUrl}/mcp/${connectionId}`, { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: The example uses Prompt for AI agents✅ Addressed in |
||
| headers: { Authorization: `Bearer ${meshToken}` }, | ||
| // ... | ||
| }); | ||
| ``` | ||
|
|
||
| ## Quando usar vs Agents | ||
|
|
||
| - Use **Conexão** para isolar e depurar um upstream específico. | ||
| - Use **Agent** para expor um surface agregado/curado para os clients. | ||
|
|
||
| ## Boas práticas | ||
| ## Construindo MCPs STDIO | ||
|
|
||
| - Mantenha URLs e credenciais por ambiente (dev/staging/prod). | ||
| - Evite expor uma connection diretamente em produção; prefira um Agent para governança. | ||
| Veja exemplos no repositório [decocms/mcps](https://github.com/decocms/mcps): | ||
|
|
||
| - `template-minimal/` - MCP mínimo sem view | ||
| - `template-with-view/` - MCP com interface web | ||
| - `local-fs/` - MCP de sistema de arquivos (roda via npx) | ||
| - `perplexity/`, `openrouter/` - MCPs em produção | ||
|
|
||
| ## Boas práticas | ||
|
|
||
| - Mantenha URLs e credenciais por ambiente (dev/staging/prod). | ||
| - Evite expor uma Conexão diretamente em produção; prefira um Agent para governança. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P2: The code example references
connectionIdwhich is never defined or explained. Consider adding a comment explaining where this value comes from, or defining it (perhaps fromstate).Prompt for AI agents
✅ Addressed in
0c31351