Observação
O acesso a essa página exige autorização. Você pode tentar entrar ou alterar diretórios.
O acesso a essa página exige autorização. Você pode tentar alterar os diretórios.
Importante
Algumas informações neste artigo estão relacionadas ao produto pré-lançado que pode ser modificado substancialmente antes de ser lançado comercialmente. A Microsoft não faz garantias, expressas ou implícitas, quanto às informações fornecidas aqui.
A coleção de ferramentas de criação de agentes no servidor do Protocolo mcP (Model Context Protocol) do Microsoft Sentinel permite que os programadores utilizem linguagem natural para criar Security Copilot agentes num IDE compatível com MCP à escolha.
Nesta introdução, vai aprender a:
Configurar e autenticar no servidor MCP
Ativar o modo de agente GitHub Copilot
Gerir o contexto das ferramentas MCP
Pré-requisitos
Para utilizar o Servidor MCP do Microsoft Sentinel e aceder às ferramentas, tem de estar integrado no data lake do Microsoft Sentinel. Para obter mais informações, consulte Integrar no data lake do Microsoft Sentinel e grafo do Microsoft Sentinel (pré-visualização).
Editores de código suportados
O suporte do Microsoft Sentinel para as ferramentas mcP de criação de agentes Security Copilot está disponível para os seguintes editores de código baseados em IA:
Configurar e autenticar no servidor MCP
Os passos para instalar o servidor MCP são os seguintes:
Inicie Visual Studio Code (VS Code).
Adicione a ligação ao servidor MCP no VS Code. Escreva Premir
Ctrl + Shift + Ppara abrir a Paleta de Comandos. Escreva o símbolo>, seguido do textoMCP: Add server.Selecione
HTTP (HTTP or Server-Sent Events).Escreva o seguinte URL do servidor e selecione Enter. Este URL é sensível às maiúsculas e minúsculas.
https://sentinel.microsoft.com/mcp/security-copilot-agent-creationIntroduza um ID de Servidor amigável.
É-lhe pedido para Confiar no servidor.
Selecione Permitir quando lhe for pedido para autenticar a definição do servidor.
Escolha se pretende disponibilizar o servidor em todas as áreas de trabalho do VS Code ou apenas na atual.
Depois de autenticado, o servidor deve iniciar Em execução e deverá ver um ficheiro com o nome
mcp.jsonque verifica as configurações do SERVIDOR MCP na área de trabalho do VS Code.
Ativar o modo de agente GitHub Copilot
Abra o menu >Ver de chat > do VS Code Chat ou prima
CRTL + ALT + I.Defina a conversa como Modo de agente.
Selecione o ícone de ferramentas na barra de pedidos.
Pode ver uma lista das ferramentas que estão a ser utilizadas pelo GitHub Copilot. Expanda a linha do servidor MCP que acabou de adicionar para ver as cinco ferramentas para a criação de agentes:
Gerir o contexto das ferramentas MCP
Ao fornecer o contexto certo, pode obter ajuda da IA no VS Code para fornecer respostas relevantes e precisas. Esta secção abrange duas opções para gerir o contexto e garantir que o assistente de IA utiliza as ferramentas MCP conforme pretendido e com maior consistência.
Pode escolher uma das seguintes opções para gerir o contexto:
Instruções personalizadas
As instruções personalizadas permitem-lhe definir diretrizes ou regras comuns num ficheiro Markdown para descrever como as tarefas devem ser executadas. Em vez de incluir manualmente o contexto em todos os pedidos de chat, especifique instruções personalizadas num ficheiro Markdown para garantir respostas de IA consistentes que se alinham com os requisitos do projeto.
Pode configurar instruções personalizadas para aplicar automaticamente a todos os pedidos de chat ou apenas a ficheiros específicos.
Utilizar um ficheiro de instruções personalizado
Defina as instruções personalizadas num único .github/copilot-instructions.md ficheiro Markdown na raiz da área de trabalho. O VS Code aplica automaticamente as instruções neste ficheiro a todos os pedidos de chat nesta área de trabalho.
Os passos para utilizar um .github/copilot-instructions.md ficheiro:
Ative a
github.copilot.chat.codeGeneration.useInstructionFilesdefinição.Crie um
.github/copilot-instructions.mdficheiro na raiz da área de trabalho. Se necessário, crie primeiro um.githubdiretório.Descreva as suas instruções com linguagem natural e no formato Markdown.
Para começar, copie o conteúdo do ficheiro
scp-mcp-context.mdde contexto para ocopilot-instructions.mdficheiro. Veja Contexto MCP.
Adicionar ficheiro de contexto
Para ajudar a garantir que o assistente de IA pode utilizar as ferramentas MCP conforme pretendido e com maior consistência, adicione este ficheiro de contexto ao seu IDE. Certifique-se de que o assistente de IA está a referir-se a este ficheiro quando o está a pedir.
Adicione o contexto
scp-mcp-context.mdao VS Code ou cole-o diretamente na área de trabalho. Utilize o ficheiro de contexto, veja Contexto MCP. A área de trabalho tem o seguinte aspeto:Selecione Adicionar Contexto na barra de pedidos e selecione o ficheiro de contexto.
Ficheiro de contexto para ferramentas MCP
Copie o scp-mcp-context.md para utilizar com o início rápido.
# MCP Tools Available for Agent Building
1. **start_agent_creation**
- **Purpose**: Creates a new Security Copilot session and starts the agent building process.
- The userQuery input will be the user's problem statement (what they want the agent to do).
- The output of the tool should be returned IN FULL WITHOUT EDITS.
- The tool will return an initial agent YAML definition.
2. **compose_agent**
- **Purpose**: Continues the session and agent building process created by *start_agent_creation*. Outputs agent definition YAML or can ask clarifying questions to the user.
- The sessionId input is obtained from the output of *start_agent_creation*
- The existingDefinition input is optional. If an agent definition YAML has not been created yet, this should be blank (can be an empty string).
3. **search_for_tools**
- **Purpose: Discover relevant skills (tools) based on the user's query
- This will create a new Security Copilot session, but it should not be included in the start_agent/continue_agent flow.
- A user might want to know about Security Copilot skills they have access to without wanting to create an agent
- The session ID created should NOT be reused in any capacity
4. **get_evaluation**
- **Purpose: Get the results of the evaluations triggered by each of the above tools. You MUST repeatedly activate this tool until the property of the result "state" is equal to "Completed" in order to get the fully processed result. The "state" may equal "Created" or "Running" but again, you must repeat the process until the state is "Completed". There is NO MAXIMUM amount of times you might call this tool in a row.
5. **deploy_agent**
- **Purpose: Deploy an agent to Security Copilot.
- The user must provide the scope as either "User" or "Workspace".
- Unless they already have an AGENT definition yaml provided, *start_agent_creation* must be run before to generate an agentDefinition
- "agentSkillsetName" should be COPIED EXACTLY from the value of "Descriptor: Name:" in the agent definition YAML, including any special characters like ".". This will NOT work if the two do not match EXACTLY.
- DO NOT use *get_evaluation* after this tool.
# Agent Building Execution Flow
## Step 1: Problem Statement Check
- If the user did **not** provide a problem statement, prompt them to do so.
- If the user **did** provide a problem statement, proceed to Step 2.
## Step 2: Start Agent Creation
- Use the `start_agent_creation` tool with `userQuery = <problem statement>`.
- **DO NOT** include any quotation marks in the userQuery
- Then, use `get_evaluation` to retrieve the initial response.
- **DO** repeatedly call `get_evaluation` until the `"state"` property of the result equals `"Completed"`.
- **DO NOT** require the user to ask again to get the results.
- **DO NOT** edit or reword the response content.
## Step 2.5: Output Handling
- **DO NOT** reformat, summarize, or describe the YAML output.
- **DO** return the YAML output **verbatim**.
- **DO** return the output in **AGENT FORMAT**.
## Step 3: Agent Refinement
- Ask the user if they would like to edit the agent or if they would like to deploy the agent. If they want to deploy, skip to **Step 4**.
- If the user wants to edit the agent definition:
- If they respond with edits directly, use `compose_agent` with:
- `sessionId` from `start_agent_creation`
- `existingDefinition = <previous AGENT YAML>`
- `\n` MUST be rewritten as `\\n`
- `userQuery = <user’s new input>`
- **DO NOT** include any quotation marks in the userQuery
- If they attach a manually edited YAML file to the context, use the file content as `existingDefinition`.
- **DO NOT** edit the file directly, you MUST use `compose_agent`
- `\n` MUST be rewritten as `\\n`
## Step 4: Agent Deployment
- If the user asks to deploy the agent, use `deploy_agent`.
- You **must confirm the scope**: either `"User"` or `"Workspace"`.
- If not provided, ask the user to specify.
- `agentSkillsetName` must **exactly match** the value of `Descriptor: Name:` in the YAML.
- This includes any special characters.
- Leave existing instances of `\n` inside `agentDefinition` as-is
- **DO NOT** run `get_evaluation` after deployment.
- **DO** include all of these things in the tool response to the user:
1. Confirm successful deployment to the user
2. Direct the user to the Security Copilot portal to test and view the agent with this link: https://securitycopilot.microsoft.com/agents
3. Direct the user to read more on how to test their agent in Security Copilot with this link: https://learn.microsoft.com/en-us/copilot/security/developer/mcp-quickstart#test-agent
## Step 5: Further Agent Refinement and Redeployment
- After deployment, the user may still want to **edit the agent definition**.
- If so, you must support calling `compose_agent` again.
- Follow the same process as described in **Step 3**:
- If the user asks for edits directly, use the previous AGENT YAML as `existingDefinition`.
- If the user uploads a manually edited YAML file, use the file content as `existingDefinition`.
- The user may also want to **redeploy the agent** after making refinements.
- You must run `deploy_agent` again using the updated YAML.
- Ensure the `agentSkillsetName` matches **exactly** the value of `Descriptor: Name:` in the latest YAML, including any special characters.
- Leave existing instances of `\n` inside `agentDefinition` as-is
- Confirm the deployment scope: either `"User"` or `"Workspace"`.
- If the scope is not provided, prompt the user to specify.
- Do **not** run `get_evaluation` after deployment.
- Confirm successful redeployment to the user.
- Alternatively, the user may want to **create a new agent**.
- Restart the procedure from **Step 1**.
- When using `start_agent_creation`, a new session ID will be created.
- **DO** keep track of which session IDs correspond to which problem statements or agents so the user can return to previous sessions if needed.
## Additional Rules
- Only call `compose_agent` **after** the user has provided a response. Do not proceed automatically.
- Agent creation must remain **user-driven**. Do not initiate steps without explicit user input.
- Wait for the user to respond before continuing to the next step.
- Tool responses must be returned **directly to the user** in full.
- Do **not** alter, reformat, summarize, or reword the content of any tool response.
- This applies specifically to the `"result": "content"` field in the JSON returned by tool executions.
- LEAVE OUT any "Grounding Notes"
## Error Handling
- If any tool call fails:
- Inform the user of the failure.
- If it is a client error, make an attempt to retry the tools, rewriting inputs based on the error message.
- Example: If the error indicates invalid JSON characters, escape or remove those characters from the input and retry. Always attempt escaping first.