Skip to content

Commit ee8c9f4

Browse files
kzr-at-amazonkzr-at-amazon
andauthored
fix(smus): Update SMUS context template with credentials provider uri for MCP servers (#8608)
## Problem Kiro struggles to troubleshoot credential issues when MCP server doesn't have the proper credentials environment variable, even though it's mentioned in the smus-context file. ## Solution Add a prompt to smus-context.md to include credentials provider uri in MCP server env block. --- - Treat all work as PUBLIC. Private `feature/x` branches will not be squash-merged at release time. - Your code changes must meet the guidelines in [CONTRIBUTING.md](https://github.com/aws/aws-toolkit-vscode/blob/master/CONTRIBUTING.md#guidelines). - License: I confirm that my contribution is made under the terms of the Apache 2.0 license. Co-authored-by: kzr-at-amazon <build@amazon.com>
1 parent 3aa2f34 commit ee8c9f4

File tree

1 file changed

+49
-20
lines changed

1 file changed

+49
-20
lines changed

packages/core/resources/smus-context-template.md

Lines changed: 49 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,25 @@ inclusion: always
77
This workspace is running on an Amazon SageMaker Unified Studio Space.
88

99
## Environment
10-
- Operating system: Ubuntu-based SageMaker Distribution
11-
- User: sagemaker-user
12-
- Home directory: /home/sagemaker-user
13-
- AWS credentials are available via the container credentials provider (AWS_CONTAINER_CREDENTIALS_RELATIVE_URI)
14-
- Do NOT hardcode AWS credentials; use the default credential chain (e.g., boto3.Session())
10+
11+
- Operating system: Ubuntu-based SageMaker Distribution
12+
- User: sagemaker-user
13+
- Home directory: /home/sagemaker-user
14+
- AWS credentials are available via the container credentials provider (AWS_CONTAINER_CREDENTIALS_RELATIVE_URI)
15+
- Do NOT hardcode AWS credentials; use the default credential chain (e.g., boto3.Session())
1516

1617
## Project Info
17-
- ~/README.md contains project-specific configuration such as connection names and available compute resources.
18-
- ~/shared/README.md contains shared project data catalog and storage information.
19-
Refer to these files when you need details about the project's connections, databases, or S3 paths.
18+
19+
- ~/README.md contains project-specific configuration such as connection names and available compute resources.
20+
- ~/shared/README.md contains shared project data catalog and storage information.
21+
Refer to these files when you need details about the project's connections, databases, or S3 paths.
2022

2123
## Project Library (`sagemaker_studio`)
24+
2225
The `sagemaker_studio` package is pre-installed and provides access to project resources.
2326

2427
### Project
28+
2529
```python
2630
from sagemaker_studio import Project
2731
project = Project()
@@ -35,6 +39,7 @@ project.s3.root # project S3 root path
3539
```
3640

3741
### Connections
42+
3843
```python
3944
project.connections # list all connections
4045
project.connection() # default IAM connection
@@ -48,6 +53,7 @@ conn.create_client("glue") # boto3 client for specific service
4853
```
4954

5055
### Catalogs, Databases, and Tables
56+
5157
```python
5258
catalog = project.connection().catalog() # default catalog
5359
catalog = project.connection().catalog("catalog_id")
@@ -59,6 +65,7 @@ table.columns # list columns (name, type)
5965
```
6066

6167
### SQL Utilities
68+
6269
```python
6370
from sagemaker_studio import sqlutils
6471

@@ -83,6 +90,7 @@ engine = sqlutils.get_engine(connection_name="project.redshift")
8390
```
8491

8592
### DataFrame Utilities
93+
8694
```python
8795
from sagemaker_studio import dataframeutils
8896
import pandas as pd
@@ -101,6 +109,7 @@ df = pd.read_catalog_table(
101109
```
102110

103111
### Spark Utilities
112+
104113
```python
105114
from sagemaker_studio import sparkutils
106115

@@ -114,19 +123,39 @@ df = spark.read.format("jdbc").options(**options).option("dbtable", "my_table").
114123
```
115124

116125
## Compute Options
117-
- **Local Python**: Runs directly on the Space instance. Use for single-machine Python, ML, and AI workloads.
118-
- **Apache Spark (AWS Glue / Amazon EMR)**: Use `%%pyspark`, `%%scalaspark`, or `%%sql` cell magics in notebooks. Default Spark connection is `project.spark.compatibility`.
119-
- **SQL (Athena)**: Use `%%sql project.athena` for Trino SQL queries via Amazon Athena.
120-
- **SQL (Redshift)**: Use `%%sql project.redshift` if a Redshift connection is available.
126+
127+
- **Local Python**: Runs directly on the Space instance. Use for single-machine Python, ML, and AI workloads.
128+
- **Apache Spark (AWS Glue / Amazon EMR)**: Use `%%pyspark`, `%%scalaspark`, or `%%sql` cell magics in notebooks. Default Spark connection is `project.spark.compatibility`.
129+
- **SQL (Athena)**: Use `%%sql project.athena` for Trino SQL queries via Amazon Athena.
130+
- **SQL (Redshift)**: Use `%%sql project.redshift` if a Redshift connection is available.
121131

122132
## Code Patterns
123-
- Use `sagemaker_studio.Project()` for project-aware sessions and resource discovery
124-
- Reference data using S3 URIs in s3://bucket/prefix format
125-
- Write Spark DataFrames to the project catalog: `df.write.saveAsTable(f"{database}.table_name", format='parquet', mode='overwrite')`
126-
- SQL query results are available as DataFrames in subsequent cells via the `_` variable
127-
- Use `sqlutils.sql()` for programmatic SQL execution against any connection
128-
- Use `pd.read_catalog_table()` / `df.to_catalog_table()` for pandas catalog I/O
133+
134+
- Use `sagemaker_studio.Project()` for project-aware sessions and resource discovery
135+
- Reference data using S3 URIs in s3://bucket/prefix format
136+
- Write Spark DataFrames to the project catalog: `df.write.saveAsTable(f"{database}.table_name", format='parquet', mode='overwrite')`
137+
- SQL query results are available as DataFrames in subsequent cells via the `_` variable
138+
- Use `sqlutils.sql()` for programmatic SQL execution against any connection
139+
- Use `pd.read_catalog_table()` / `df.to_catalog_table()` for pandas catalog I/O
129140

130141
## MCP Server Configuration
131-
- When configuring MCP servers, pass AWS credentials via environment variable expansion:
132-
"AWS_CONTAINER_CREDENTIALS_RELATIVE_URI": "${AWS_CONTAINER_CREDENTIALS_RELATIVE_URI}"
142+
143+
MCP servers in this environment may need AWS credentials forwarded from the container. If an MCP tool returns "Unable to locate credentials", add the `env` block to the affected server in MCP server config file:
144+
145+
```json
146+
{
147+
"mcpServers": {
148+
"example-server": {
149+
"command": "uvx",
150+
"args": ["example-server@latest"],
151+
"env": {
152+
"AWS_CONTAINER_CREDENTIALS_RELATIVE_URI": "${AWS_CONTAINER_CREDENTIALS_RELATIVE_URI}"
153+
},
154+
"disabled": false,
155+
"autoApprove": []
156+
}
157+
}
158+
}
159+
```
160+
161+
If you cannot edit the config directly, suggest the user add the `env` block to their MCP server entry in MCP server config.

0 commit comments

Comments
 (0)