Skip to content

Commit a7a69fa

Browse files
committed
Add more docs
1 parent 9a4fa2a commit a7a69fa

18 files changed

+182
-1
lines changed

backstage/values-templated.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ ingress:
183183
extraDeploy:
184184
- apiVersion: v1
185185
data:
186-
users.yaml: |
186+
config.yaml: |
187187
---
188188
apiVersion: backstage.io/v1alpha1
189189
kind: User

docs/end-to-end/lab-guide.md

Lines changed: 181 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1980,6 +1980,187 @@ The BACKStack approach supports platform maturity:
19801980
- Cost optimization and chargeback
19811981
</details>
19821982

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+
![Agent Forge](../images/ai/agent-forge.png)
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+
![MCP Chat](../images/ai/mcp-chat.png)
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+
![Copilot](../images/ai/copilot.gif)
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+
![AWS](../images/ai/aws.png)
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.
2011+
2012+
## BACKStack MCP Servers
2013+
- [**ArgoCD MCP Server**](https://github.com/argoproj-labs/mcp-for-argocd)
2014+
- [**Kyverno MCP Server**](https://github.com/nirmata/kyverno-mcp)
2015+
2016+
2017+
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:
2018+
- [**Containers Org Kubernetes MCP Server**](https://github.com/containers/kubernetes-mcp-server)
2019+
- [**Flux159 Kubernetes MCP Server**](https://github.com/Flux159/mcp-server-kubernetes)
2020+
2021+
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+
![MCP JSON](../images/ai/mcp-json.png)
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+
![Allow Auth](../images/ai/allow-auth-flow.png)
2053+
2054+
- Next we may be asked to acknowledge we are accessing a codespaces port-forwarded address and we should click **continue**.
2055+
2056+
![Access Dev Port](../images/ai/allow-access-to-codespace-port.png)
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+
![Login Screen](../images/ai/oauth-login.png)
2061+
2062+
- Now we need to allow VSCode access to Backstage by clicking **Authorize**
2063+
2064+
![Authorize](../images/ai/allow-vscode-to-auth.png)
2065+
2066+
- Finally We will see that Authentication succeeded and we can close the browser tab
2067+
2068+
![Auth Done](../images/ai/auth-done.png)
2069+
2070+
Now that the MCP server is added, configured and authenticated we should see that it has discoverewd 8 tools!
2071+
2072+
![running MCP Server](../images/ai/running-json.png)
2073+
2074+
Let's explore the available tools, and what they can provide us.
2075+
2076+
### Exploring the Available tools
2077+
In the Codespaces Copilot Chat Tab make sure the mode is set to **Agent** and that preferably a Claude model is selected for best results.
2078+
2079+
![Settings](../images/ai/copilot-chat-settings.png)
2080+
2081+
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+
![Create](../images/ai/create.png)
2141+
2142+
We can then click on the 3 dots at the top to show the available options
2143+
2144+
![OPtions](../images/ai/options.png)
2145+
2146+
And if we select **Installed Actions** we can see the auto-generated docs for the installed and available Scaffolder actions.
2147+
2148+
![available actions](../images/ai/installed-actions.png)
2149+
2150+
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
2151+
2152+
![crossplane tool docs](../images/ai/crossplane-example.png)
2153+
2154+
### 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.
2161+
2162+
</details>
2163+
19832164
# Summary
19842165
<details>
19852166
<summary>Summary Of The Workshop</summary>

docs/images/ai/agent-forge.png

393 KB
Loading
36.8 KB
Loading

docs/images/ai/allow-auth-flow.png

20.8 KB
Loading
115 KB
Loading

docs/images/ai/auth-done.png

4.75 KB
Loading

docs/images/ai/aws.png

109 KB
Loading
7.84 KB
Loading

docs/images/ai/copilot.gif

35.9 MB
Loading

0 commit comments

Comments
 (0)