Important
Microsoft Visio Desktop MCP is in preview. Preview software is for evaluation and isn't intended for production environments or critical workloads. Features might change before general availability.
A custom agent is a set of instructions that tells your AI agent how your team works with Visio: which shapes to use, what to check, and when to stop and ask. You write the rules once, and everyone who uses the agent gets the same behavior.
This article uses custom agents in GitHub Copilot for Visual Studio Code as the example. Other AI clients have their own ways to define reusable agent instructions, and the same rules apply.
When to use a custom agent
| Use | When | Example |
|---|---|---|
| A prompt | The request is a one-off. | "Add a Manager check-in step after orientation." |
| A custom agent | A team makes the same kind of diagram often, with the same rules. | A Visio Architecture agent that every architect uses. |
| Benefits | Trade-offs |
|---|---|
| Consistent results. Everyone follows the same shapes, labels, Shape Data, and checks. Results can still vary between runs. | Setup work. You need to write and test the instructions with your actual stencils. |
| Shorter prompts. People say what they need; the agent knows how. | Less flexible. Strict rules can get in the way of one-off diagrams. |
| Built-in checks. The agent is told to check its work every time. Confirm that it did. | Upkeep. Instructions need updates when your standards change. |
| Safer edits. The agent reads before it edits, and stops instead of guessing. | Still needs review. People should still review diagrams. |
Create the agent
Make sure that you've set up Visio Desktop MCP and that its tools are available.
In Visual Studio Code, press Ctrl+Shift+P, and then run Chat: New Custom Agent. Choose where to save it, and name the file
visio-architecture.agent.md:To share it with Save it in Your team, in a project The .github\agentsfolder of the projectOnly yourself, in all projects The user location that Visual Studio Code offers At the top of the file, add a header that names the agent and gives it the Visio Desktop MCP tools:
--- name: Visio Architecture description: Creates and updates architecture diagrams with approved Visio shapes. tools: ['read', 'search', 'visio-local/*'] ---visio-local/*gives the agent all the tools from the server namedvisio-local. If you named the server something else, use that name. The tool list doesn't set up the server or skip any approval prompts.Below the header, add your instructions. For what to cover, see What to include in your instructions. You can start from the example instructions.
In Visual Studio Code, select the agent from the agent list in the Chat view.
Try it with a small diagram, review the result, and refine the instructions.
For more information, see Custom agents in Visual Studio Code.
What to include in your instructions
Good instructions tell the agent what to make, how your team makes it, and when to stop and ask. Most agents cover these areas, but you only need the ones that apply to your diagrams.
| Area | What to include | Example |
|---|---|---|
| Purpose | The kind of diagram the agent makes. | "You create and update architecture diagrams." |
| Source | Where the content comes from, and what the agent must keep exactly as given. | "Use only the source the user provides. Keep IDs and names exactly as given." |
| Shapes | The stencil and shape for each kind of item, and what to do if a shape can't be found. | "Service: ApprovedArchitecture.vssx, Service." |
| Structure and style | The template to start from, page layout, containers or swimlanes, connectors, and theme. | "Start from C:\Templates\Architecture.vstx. Flow left to right." |
| Shape Data | The fields to fill in for each kind of shape, and which ones are required. | "Add Owner and Environment to every Application." |
| Existing diagrams | How to change a diagram without losing other content. | "Read the diagram first, and change only what was asked." |
| When you finish | The checks to run, how to save or export, and what to report. | "Read the diagram back, check the layout, and report the file path." |
| Stop and ask | When the agent should ask instead of guessing. | "A shape can't be found, or the same step fails twice." |
Be specific. Name your actual stencils, shapes, templates, and Shape Data fields, and write rules that you can check in the finished diagram.
Example instructions
Copy this example below the header, and replace the shape list with your own stencil and shapes.
# Visio Architecture Agent
You create and update Visio architecture diagrams by using the Visio Desktop MCP tools.
## Rules
- Use only the source the user provides.
- Never add components, connections, owners, or Shape Data that aren't in the source.
- Keep IDs, names, and connection labels exactly as given.
- Use connectors with arrows for connections, and real containers for boundaries.
## Shapes
- Search for shapes before you draw, and confirm which stencil each shape comes from.
- Use the same shape for every item of the same type:
- Application: ApprovedArchitecture.vssx, Application
- Service: ApprovedArchitecture.vssx, Service
- Data store: ApprovedArchitecture.vssx, Data Store
- If a shape can't be found, stop and tell the user. Don't use a different shape.
## Before you draw
- Open Visio, then create or open the diagram, and work on the page the user names.
- Treat page changes as separate from changes to page content.
## Existing diagrams
- Read the diagram first, change only what was asked, and keep everything else.
- Don't close the diagram just to keep editing it.
## When you finish
1. Read the diagram back and compare it with the source.
2. Check the layout and fix any problems, then check again.
3. Save only as the user asked. If you didn't save, say that the changes are unsaved.
4. Report the full file path, what you checked, and anything the user should review.
5. Treat exports as separate files. Exporting doesn't save the diagram.
## Stop and ask when
- Information is missing, or a shape can't be found.
- A change conflicts with something the user asked to keep.
- The same step fails twice.
With this agent, a user only needs to say:
Create an architecture diagram from inventory.csv, and save it as a new file named inventory-architecture.vsdx.
Tips
- Keep each agent focused on one kind of diagram.
- Store team agents in source control, and review changes to them.
- Update the agent when your standards or stencils change.
- Test both new diagrams and focused changes. One good diagram doesn't prove that every rule works.
Custom agents use the existing Visio Desktop MCP tools. They don't install stencils, add new capabilities, give access to more files, or skip your AI client's approvals and your organization's controls.
Related topics
Use your organization's shapes