PUBLICLY SHARED
This document has been closed to further comments while we process feedback. Thank you! |
Enable packages to directly expose documentation, prompts, or other features to AI Agents
Author: Jake MacDonald (@jakemac53)
Go Link: flutter.dev/go/packaged-ai-assets
Prototype: https://github.com/dart-lang/ai/tree/packaged-ai-assets-prototype
Created: 1/2026 / Last updated: 4/2026
Status: Implementation starting
With the growing popularity of AI coding agents, it is only natural that package authors will want to improve the performance of their packages in these agents, by exposing relevant information, guides, custom commands, etc to those agents.
Today, this requires shipping something separate from the actual package, whether that be an MCP server, extension, or just a repo of prompts/skills. This requires manual work for your users and also has a discoverability barrier to adoption. Additionally, many of the emerging tools in this space require node/npx which should not be a requirement for Dart/Flutter development.
The objective of this document is to provide a way for package authors to automatically include these resources, via the Dart/Flutter MCP server. This way, there is only one tool to install, and any time you add a new package or update a package, all the relevant Agent related features will be up to date.
Package authors and users of AI coding Agents.
At a high level, the proposal is to provide a configuration file following the package:extension_discovery format, at extension/mcp/config.yaml which describes all the AI Agent related resources provided by the package. The Dart/Flutter MCP server will read these files from your immediate dependencies, and surface the resources directly to your AI Agent.
Consider the flutter package itself as an example, we could ship a structure like the following in the flutter repo:
packages/
.. flutter/
.... extension/
...... mcp/
........ config.yaml
........ resources/
.......... slivers/
............ really_awesome_doc_on_slivers.md
........ prompts/
.......... widgets/
............ split_up_into_subwidgets.md
config.yaml:
resources:
# A custom resource just for agents
- name: slivers_tutorial # Defaults to the basename of the path
title: "Slivers Tutorial"
description: "Become a slivers expert with this doc!"
path: resources/slivers/really_awesome_doc_on_slivers.md
# A resource pointing to an existing example
- title: "Using a ListBuilder for an infinite scrolling list"
description: "End to end example of implementing an infinite scrolling list with a ListBuilder"
path: ../../example/list_builder_example.dart
prompts:
- name: split_into_subwidgets # Defaults to the basename of the path
title: "Split into subwidgets"
description: "Splits a widget up into multiple widgets"
path: prompts/widgets/split_up_into_subwidgets.md
Package Consumers:
A consumer of the flutter package connects their agent to the Dart MCP Server, and the following things happen:
Resources are listed under the resources key of the config.yaml file.
This is a simple list of resource objects, matching the MCP Resource schema with the exception of a couple small differences:
Note: Providing the full package relative path in the URI allows resources to live anywhere in the package, so you can reference things under example/ , docs/, etc.
Alternative: We could just use the actual (file:) URI of the package root, but this would often be a pub cache path and we probably don’t want agents mucking about in there. This is also potentially more flexible for non-file based environments.
Prompts are listed under the prompts key of the config.yaml file.
This is a simple list of prompt objects, matching the MCP Prompt schema, with a few small differences:
Prompt names will also be prefixed with the package name, when surfaced by the Dart MCP server.
MCP prompts support arguments, which all must be strings (repeated arguments are not supported by the MCP spec).
If any arguments are provided for a prompt, then the prompt file will be parsed as a mustache template using package:mustache_template, with the provided arguments.
The visibility field defaults to public, but may be set to private. Additional visibility options may be added in the future.
Note that MCP features cannot be scoped to portions of a workspace, so private functionality will be exposed if the package is a part of any MCP root - which typically corresponds to the current working directory or all open directories in your editor.
All public features will be exposed to the current package as well as any package directly depending on this package.
It has been expressed by some package authors that they are concerned about the extra overhead supporting these features may incur above and beyond the normal duties of package maintenance. There are several potential facets to this:
As a core part of the ecosystem, users of packages may more aggressively file issues on these packages asking for AI support, beyond what they already do.
This could be highly distracting and annoying for package authors.
Mitigation: We should emphasize in our own documentation that this support is optional. Not all packages need this support if they are well established and LLMs understand them well. Or package authors may choose not to provide this support for any reason. We can also direct users towards releasing their own packages that can be paired with an existing package, but provide just the AI support for it.
An additional aspect that would feed into this is pub package scoring. If we were to penalize packages based on not providing these AI resources, then that would further push package authors to spend time on these resources, when they would rather not do so.
Mitigation: We will not penalize pub package scores for not having AI support files.
This proposal does explicitly enable, and even promote as a valid option, the shipping of packages which only provide AI support for Dart/Flutter development, and no Dart code.
There is some risk that pub could become swamped with LLM related packages of little value, which would then make it less useful as a whole.
Decision: While this concern is heard, the team (including representatives from the pub package manager) has decided that this is an appropriate use of pub. There is established precedent here as well with packages that only publish analysis_options.yaml files, which has worked out well. Pub already has scoring mechanisms and voting to address some of these concerns and these can be extended as needed.
Yes, it is true that any package containing AI resources will need to publish any time they want to release new versions of those resources.
The proposal does not allow pointing to external websites as a risk mitigation for prompt injection which would otherwise be one way of avoiding this.
Solution: This proposal allows for putting your AI assets in a separate package if that makes the most sense for your package. This may be an appropriate choice for some packages. In general though, changing these assets is not a breaking change, and authors should feel fine about releasing their package as often as they see fit.
Packages may become larger due to including these assets, whether as a result of the configuration file itself or any additional resources they point to.
These are generally just text files, and the bloat should be minimal. We already ship many more things with packages than just what is strictly needed to use the package - we ship everything in the package unless explicitly excluded. This includes any documentation, examples, tests, etc.
Decision: The risk here is minimal and not of concern. Packages do have a maximum size limit as well to mitigate this.
This is actually a fairly common case - people often have multiple packages open at once. In this case we will surface the resources and prompts from the latest version found in any open package.
This is a pragmatic solution that reduces duplication and ensures our URIs can be kept short. When choosing a version of a package to surface, the latest one is the obvious choice, but there will be edge cases where docs are incorrect when working on multiple packages with different versions of packages simultaneously.
Our data may become out of date whenever the set of package dependencies changes, or a new package is added to the current workspace.
For an initial release, we will not try to solve this problem. You will have to restart the MCP server after altering dependencies in order to get updated AI assistance features. Similarly editing your own features will require a restart of the server.
Many AI Agents will not respect the change notifications for MCP features anyways, so this would likely be wasted effort to implement at this time.
We may look for new package configs when new “roots” are added (adding a folder to your VsCode workspace as an example).
We will also may watch the package config files and config.yaml files that we did load for changes, and update the resources accordingly.
This proposal does potentially open up easier avenues for prompt injection, if a malicious or compromised package decides to do so. However, it is already possible for agents to read any files shipped with a package, so the risk is already there to some extent.
Ultimately, it is up to the MCP clients in this case to guard against malicious prompt injection. All MCP servers should be treated as untrusted already, similar to any content on the internet.
We will look into the best way to mitigate the security risk before proceeding, and determine if some action is necessary.
This can be unit and integration tested within the dart-lang/ai repo, where the MCP server is developed, using the same strategies as other features there.
We should add documentation to this to the pub package layout page, as well as the Dart MCP server page.
Instead of relying on specifically authored prompts/resources, we could try and automatically include certain resources/docs, such as examples.
We may still choose to do something like this in the future, but I view this is a distinctly different feature from what is proposed here, which are curated resources and prompts.
These files can also be auto generated if desired, so tooling can be built to automatically generate resources pointing to all your examples etc.
In general the team feels that pub is the correct distribution mechanism here. The goal is to make things as easy as possible on both package authors and package consumers.
Having a separate registry or distribution mechanism which delivers the same value as this proposal would add more work for authors, make these resources less discoverable, and would likely just decrease usage.
It should also not be a requirement to install Node or any other tooling in order to use these features, which many of the alternatives would likely be based on.
PUBLICLY SHARED