You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/end-to-end/lab-guide.md
+181Lines changed: 181 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1980,6 +1980,187 @@ The BACKStack approach supports platform maturity:
1980
1980
- Cost optimization and chargeback
1981
1981
</details>
1982
1982
1983
+
# Bringing AI Into The Mix
1984
+
<details>
1985
+
<summary>AI in the BACKStack</summary>
1986
+
1987
+
## AI Plugins In Backstage
1988
+
One of the ways to integrate AI into our environment is by adding plugins into our Backstage instance.
1989
+
1990
+
There are multiple options already available in the community for this:
1991
+
- [**Agent Forge**](https://github.com/backstage/community-plugins/tree/main/workspaces/agent-forge/plugins/agent-forge) - A Backstage plugin which integrates with the CNOE project called CAIPE (Commnity AI Platform Engineering) to provide specialized chatbots with specified Agents for different elements in the stack directly into the Backstage UI.
1992
+
1993
+

1994
+
1995
+
- [**MCP Chat**](https://github.com/backstage/community-plugins/tree/main/workspaces/mcp-chat/plugins/mcp-chat) - A Backstage set of plugins providing a powerful MCP based chatbot directly in the Backstage UI
1996
+
1997
+

1998
+
1999
+
- [**Copilot**](https://github.com/backstage/community-plugins/tree/main/workspaces/copilot/plugins/copilot) - A Backsytage set of plugins giving visibility and insights into GitHub Copilot usage within you companies GitHub organization
2000
+
2001
+

2002
+
2003
+
- [**AWS Labs GenAI**](https://github.com/awslabs/backstage-plugins-for-aws/blob/main/plugins/genai/README.md) - A set of backstage plugins which provide a Chatbot interface in Backstage which can leverage the roader Backstage plugin ecosystem, by exposing different plugins endpoints as tools to the AI Agent.
2004
+
2005
+

2006
+
2007
+
2008
+
Each of these approaches are about bringing AI interfaces into Backstage, and each has a unique and powerful set of capabilities worth evaluating.
2009
+
2010
+
Another approach is to utilize MCP servers for some of the relevant projects, which have official MCP servers.
While Crossplane does not have an official MCP Server, as it is based on Kubernetes completely, any Good Kubernetes MCP server good be used to gain some benefit for Crossplane as well such as:
This just leaves Backstage. Actually Backstage has a built-in MCP server which takes a very unique and powerfull approach.
2022
+
2023
+
## Backstage As An MCP Server
2024
+
Backstage has a new capability since Backstage 1.40, allowing us to turn Backstage into a remote MCP server, supporting both SSE (deprecated) and Streamable HTTP protocols. This capability also supports the MCP OAuth specification, supporting dynamic client registration. This allows us to expose backstage plugin capabilities as MCP tools in an aggregated MCP server provided by backstage, and for the same auth and RBAC which is configured in Backstage the portal to also be enforced in our MCP interface to Backstage!
2025
+
2026
+
In this demo einvironment we have included a few plugins which implement the new MCP tool capabilities which we can test in this environment.
2027
+
2028
+
### View configuration
2029
+
In your environment you can navigate to the relevant MCP config file located [here](../../.vscode/mcp.json)
2030
+
2031
+

2032
+
2033
+
As you can see we have a simple MCP JSON which is pointing at our backstage instance. no authentication details are added to this file, as we will be utilizing the new support for OAuth integration in the MCP server to utilize our Backstage credentials instead of hard coding a token.
2034
+
2035
+
Before we can utilize this MCP server, in Codespaces, you must change the relevant port forwarding instance to be a publicly visibile port.
2036
+
1. Go to the the **ports** tab
2037
+
2. Right click on the line of the port **443** port forwarding configuration
2038
+
3. under the submenu titled **Port Visibility** select **Public**
2039
+
2040
+
Now that our port is configured as a publicly available port, we can go back to our [MCP JSON file](../../.vscode/mcp.json) and make one final change.
2041
+
2042
+
We need to change the URL from localhost to be the FQDN of our backstage instance which can be done by running:
2043
+
```bash
2044
+
sed -i "s/localhost/${CODESPACE_NAME}-443.${GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN}/g" .vscode/mcp.json
2045
+
```
2046
+
2047
+
Finally we can click on the start button in the JSON file above the Backstage MCP server to start the MCP Server connection.
2048
+
2049
+
### Auth Flow
2050
+
- You will be asked to allow the auth flow which we must allow
2051
+
2052
+

2053
+
2054
+
- Next we may be asked to acknowledge we are accessing a codespaces port-forwarded address and we should click **continue**.
2055
+
2056
+

2057
+
2058
+
- Next we will be redirected to a Backstage Login page if not already logged into Backstage, and we should auth with the GitHub authentication
2059
+
2060
+

2061
+
2062
+
- Now we need to allow VSCode access to Backstage by clicking **Authorize**
Now that the chat is configured lets ask it what tools it has available for example asking:
2082
+
2083
+
```text
2084
+
what mcp tools do you have available?
2085
+
```
2086
+
2087
+
We will get a response similar to:
2088
+
2089
+
```md
2090
+
I have the following MCP (Model Context Protocol) tools available:
2091
+
2092
+
Backstage Catalog Tools:
2093
+
* mcp_dev_get-catalog-entity - Get a single entity from the software catalog by name, kind, and namespace
2094
+
2095
+
* mcp_dev_validate-entity - Validate catalog-info.yaml file contents for syntax and entity rules
2096
+
2097
+
2098
+
Crossplane Tools:
2099
+
* mcp_dev_get_crossplane_resources - Get Crossplane resources and their dependencies for a Backstage entity
2100
+
2101
+
* mcp_dev_get_crossplane_resource_graph - Get a graph of related Crossplane resources (V1 API)
2102
+
2103
+
* mcp_dev_get_crossplane_events - Get events for a specific Crossplane resource
2104
+
2105
+
Kyverno Policy Tools:
2106
+
* mcp_dev_get_kyverno_policy_reports - Get policy reports for a given entity
2107
+
2108
+
* mcp_dev_get_kyverno_crossplane_policy_reports - Get policy reports for Crossplane resources (claims and composites) associated with an entity
2109
+
2110
+
* mcp_dev_get_kyverno_policy - Get details of a specific Kyverno policy
2111
+
These tools integrate with your Backstage environment to query the software catalog, inspect Crossplane infrastructure resources, and check Kyverno policy compliance for entities and resources in your Kubernetes clusters.
2112
+
```
2113
+
2114
+
So now that we see what is available let's ask it some questions:
2115
+
2116
+
```text
2117
+
get my backstage catalog entity my-web-app, and find the crossplane resources related to it, as well as any policy violations for these resources
2118
+
```
2119
+
2120
+
Follow Up query:
2121
+
2122
+
```text
2123
+
explain to me the full policy which im failing on for this entity
2124
+
```
2125
+
2126
+
While this is a simple example, it shows what is possible with this new and unique approach.
2127
+
2128
+
Let's see what it takes to expose a tool from a plugin.
2129
+
2130
+
For example in our Kyverno plugin we have 3 tools configured. lets explore one of them which can be seen [here](https://github.com/TeraSky-OSS/backstage-plugins/blob/b18caab88f503cbbd041c1d65f10c44790d4d4d9/plugins/kyverno-policy-reports-backend/src/actions.ts#L68-L98).
2131
+
2132
+
As we can see in that file, we are simple registering a new action/tool with a title, name and description, providing the input and output schemas using zod, and finally, we have an action section where we are calling the existing backend function **service.getPolicy** with the inputted data and returning our data back to the AI Agent from the MCP tool.
2133
+
2134
+
In this approach we have complete reuse of the backend logic, with a simple wrapper around the core logic, while not requiring any AI or MCP specific knowledge to get this running.
2135
+
2136
+
One of the great elements of this feature as well, is that all of these MCP tools we expose are not just available as MCP tools, but they are also made available as Scaffolder actions, which we can use in our Software Templates.
2137
+
2138
+
To see the actions available in our instance we can get to the ***Create** tab in our backstage instance
2139
+
2140
+

2141
+
2142
+
We can then click on the 3 dots at the top to show the available options
2143
+
2144
+

2145
+
2146
+
And if we select **Installed Actions** we can see the auto-generated docs for the installed and available Scaffolder actions.
And we can then search for one of our actions, which when created as MCP tools like in this example, are prefixed with the plugin name they are registered from for example crossplane or kyverno
### Value Proposition of the BAckstage MCP Approach
2155
+
The Backstage MCP approach is a unique approach which has the following key benefits:
2156
+
* Support for easily exposing Backstage core functionality as well as any plugins features as MCP tools with very little extra config or code.
2157
+
* Allow sharing nearly all logic between the MCP tools and the Backend plugins methods being used by the frontend
2158
+
* Allows defining authn/authz once and using the same constructs across different interfaces
2159
+
* Allows for a single MCP server to be configured in End Users systems, with support for countless backend tool providers based on the plugins available in your Backstage instance
2160
+
* Allows using the same MCP tools via systems like Cursor or Copilot, as well as in Scaffolder Software Templates, again reducing maintenance, duplication of code, and divergence of features across different interfaces.
0 commit comments