Connecting a Vision MCP Service to a Text-Based LLM for Architecture Diagram Recreation

    This guide explains how to connect a vision understanding MCP service to an AI coding tool, so a text-only model can work from a reference diagram and a feature document. It covers how the vision service and the main model divide the work, how to configure and protect the service's API key, a five-step recreation workflow, when to use a feature module diagram versus an architecture diagram, and the limits of this approach.

    The short answer: a text-only model cannot read images directly. But after you connect a vision understanding MCP service to an AI coding tool, the vision service reads the image first and returns a text description. The main model then uses that description to generate diagram code. This approach works well for keeping diagram styles consistent across a team and for drafting architecture diagrams from feature documents. The steps below follow the order you would use in practice.

    1. Roles: Who Reads the Image and Who Draws It

    The Model Context Protocol (MCP) defines how hosts, clients, and servers communicate. An AI coding tool usually acts as the host. Its built-in MCP client connects to each server. The vision understanding MCP is a separate server. It receives an image, calls a model with vision capabilities, and returns a text description or structured JSON. The main model only reads these text results. It never receives the image pixels directly.

    This split has two practical effects. First, you can change the vision service without changing the main model. Second, the vision service may miss details such as very small fonts or similar colors, so you still need to check the final diagram manually.

    The main model outputs Mermaid or ECharts code as text. The tool or front end renders that code into a diagram. Mermaid code renders in Markdown editors or documentation sites that support it. An ECharts configuration must go into a web page or project that can run it.

    2. Configuring the Vision Understanding MCP

    The configuration is usually a JSON block. The example below uses placeholders and will not run as written:

    1. {
    2. "type": "stdio",
    3. "command": "npx",
    4. "args": ["-y", "<vision-mcp-package-name>@<pinned-version>"],
    5. "env": {
    6. "VISION_API_KEY": "${VISION_API_KEY}",
    7. "VISION_MODE": "IMAGE_ANALYSIS"
    8. }
    9. }

    Each field has a specific role. type is set to stdio, which means the server communicates with the client through standard input and output. command and args define the command that starts the server. Replace them with the real package name of the service you choose, and pin a fixed version so that an automatic upgrade does not change its behavior. env passes runtime settings. The valid values for VISION_MODE depend on the service documentation.

    The location of the configuration file varies by tool. It is usually a MCP settings file in the project directory or the user directory. See the official documentation for your tool.

    Key management is the step where mistakes happen most often. The ${VISION_API_KEY} syntax only references an environment variable. Whether your tool supports this syntax also depends on the tool. Whichever method you use, follow these rules:

    • Store the key only in a system environment variable or a secrets manager. Never write it into a configuration file or source code.
    • Create a sub-key with the smallest permissions the vision service needs. Do not use your account’s master key.
    • Make sure the MCP configuration file is never committed to a code repository. Add it to .gitignore if needed.
    • Rotate keys regularly. If a key leaks, revoke it immediately in the provider’s dashboard.

    After you finish the configuration, restart the tool. Then check the MCP status panel or a diagnostic command to confirm that the vision service is connected and lists its tools. Next, upload a test image that contains two boxes and an arrow, and ask the model to describe it. If the description is accurate, the full pipeline works.

    Common problems and fixes:

    Symptom Likely Cause Fix
    The service does not appear in the list The configuration file path is wrong, or the JSON syntax is invalid Check the syntax with a JSON validator, and confirm the file path
    The service exits right after starting Node.js is not installed on the machine, or npx is not on the PATH Run npx --version in a terminal to confirm it works
    Calls fail with an authentication error The environment variable name does not match, or the key has expired Check the variable name, and generate a new key if needed
    The service connects but descriptions are inaccurate The screenshot resolution is low, or the mode setting is wrong Use a clearer screenshot, and check the valid values for VISION_MODE

    3. Recreating a Diagram from a Reference Image

    The workflow has five steps.

    1. Enter plan mode. In plan mode, the model lists the execution steps without generating code right away. You can review the steps before execution and correct any drift.
    2. Paste the reference image. How you add an image depends on the tool. Check the tool’s settings for the correct input method.
    3. Extract visual features. Ask the model to list node shapes, corner radii, colors, hierarchy, and connector styles. Request exact color values so you can compare them later. Ask for the output as a checklist so you can verify each item.
    4. Generate code from the document. Provide a structured feature module document in Markdown. The model analyzes how the document divides features, combines that with the visual features extracted earlier, and outputs Mermaid or ECharts code. At this step, the model only produces code text. The tool or front end handles rendering.
    5. Render and verify. Render the diagram in a Markdown preview or project page. Compare it with the reference image and check the number of nodes, colors, layout, and text.

    In the sample used in this article, the generated diagram matched the reference image closely in style, colors, and layout. It produced a usable result in a single conversation round. This shows that the sample can be reproduced. It does not mean every diagram will turn out the same way. Complex layouts, subtle color differences, and dense connector lines usually still need manual review, and they may take several rounds of correction.

    4. Without a Reference Image: Feature Diagrams vs. Architecture Diagrams

    Without a reference image, the model relies on the document content and general system design knowledge to generate the diagram. The two diagram types emphasize different things. Use the table below to decide which type to generate.

    Dimension Feature Module Diagram System Architecture Diagram
    Focus Division of business modules and user-visible features Interactions between components, data flow, and deployment
    Main elements Business modules, features, business processes Services, databases, message queues, gateways, external dependencies
    Granularity Coarse, grouped by business domain Fine, grouped by process or service
    Primary readers Product managers, business stakeholders, testers Developers, operations engineers, architecture reviewers

    In practice, the model explains the difference between the two diagram types before it generates the diagram. This explanation helps confirm that the model understood your request. However, it is the model’s summary based on its training knowledge. It does not prove that the model understands your specific system.

    The model may add components that are not in the document, such as a cache or a message queue. After generation, check each component against your actual system. If the document describes components poorly, update the document before generating the diagram.

    5. Suitable Use Cases, Limits, and Alternatives

    This approach fits these scenarios: you already have a feature document and need a quick draft, your team wants consistent diagram styles, or diagrams must stay in sync with documents that change over time.

    It does not fit these scenarios: you need an exact deployment topology, the diagram must align precisely or serve as a formal design document, or the architecture information is sensitive and you cannot control how the vision service handles data. Both the images and the documents are sent to a third-party service. Before you use it, check the provider’s data retention and privacy terms.

    If these conditions do not apply, consider these alternatives:

    • Text-only Mermaid generation. This does not depend on a vision service. The model generates code directly from the document, which suits quick drafts.
    • Traditional diagramming tools, such as draw.io or Visio. These suit formal design work and manual refinement.
    • A style specification file. Write the color palette, node styles, and layout rules as a text specification, and ask the model to follow it. This way, you do not need to upload a reference image each time.

    Acceptance Checklist

    • The vision MCP service shows as connected, and its description of the test image is accurate.
    • The API key exists only in environment variables or a secrets manager. No plaintext key appears in the configuration files or the code repository.
    • The generated code displays correctly in the target rendering environment.
    • Each node in the diagram corresponds to a feature or component in the document.
    • Colors, layout, and text have been compared item by item with the reference image.
    • Components that do not appear in the document are marked for confirmation.

    The vision MCP service solves the problem of letting the model read images. Whether the diagram is correct still depends on the quality of the document and manual review. Handling reading, generation, rendering, and verification as separate steps helps a team turn documents into architecture diagrams more reliably.