Guide · Amazon Redshift Spectrum · S3 Data Lake · External Tables · MCP Server Tools
Redshift Spectrum for MCP Servers — External Tables, S3 Data Lake, Glue Catalog
Redshift Spectrum extends a Redshift cluster or Serverless workgroup to query files in Amazon S3 directly — no data loading, no ETL pipeline, no COPY command. An MCP tool can query petabytes of raw log files, Parquet exports, or Iceberg tables in S3 with the same SQL interface it uses for Redshift-native tables. The key architecture: you create an external schema in Redshift that maps to an AWS Glue Data Catalog database, then reference external tables in that schema. Spectrum pushes predicates down to the S3 layer — only the blocks of Parquet or ORC files needed for the query filters are transferred over the network. This guide covers the complete setup: IAM role prerequisites, external schema creation with Glue integration, external table DDL for common file formats, partition projection for time-series data, Lake Formation permissions, query cost optimization, and the specific limitations that affect MCP tool design.
TL;DR
Create a Redshift IAM role with AmazonS3ReadOnlyAccess + AWSGlueConsoleFullAccess and trust redshift.amazonaws.com. Run CREATE EXTERNAL SCHEMA spectrum FROM DATA CATALOG DATABASE 'glue-db' IAM_ROLE 'arn:...' REGION 'us-east-1' in Redshift. External tables defined in the Glue catalog are immediately queryable via SELECT * FROM spectrum.tablename. Use Parquet with Snappy compression for best Spectrum performance — it pushes column pruning and predicate filtering to the S3 tier. Add partition projection to avoid Glue Catalog partition-count limits on time-partitioned tables. Spectrum charges $5 per TB of S3 data scanned; always filter on partition columns in WHERE clauses to minimize scan cost.
IAM prerequisites
Spectrum queries run via an IAM role that the Redshift cluster or workgroup assumes when accessing S3 and the Glue catalog. This role is distinct from the IAM principal that calls the Data API — it is attached to the Redshift resource itself.
# Create the Spectrum IAM role
aws iam create-role \
--role-name RedshiftSpectrumRole \
--assume-role-policy-document '{
"Version": "2012-10-17",
"Statement": [{
"Effect": "Allow",
"Principal": { "Service": "redshift.amazonaws.com" },
"Action": "sts:AssumeRole"
}]
}'
# Attach S3 and Glue access
aws iam attach-role-policy \
--role-name RedshiftSpectrumRole \
--policy-arn arn:aws:iam::aws:policy/AmazonS3ReadOnlyAccess
aws iam attach-role-policy \
--role-name RedshiftSpectrumRole \
--policy-arn arn:aws:iam::aws:policy/AWSGlueConsoleFullAccess
For production, replace the AWS managed policies with a least-privilege inline policy scoped to your specific S3 bucket and Glue database:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": ["s3:GetObject", "s3:ListBucket"],
"Resource": [
"arn:aws:s3:::my-data-lake-bucket",
"arn:aws:s3:::my-data-lake-bucket/*"
]
},
{
"Effect": "Allow",
"Action": [
"glue:GetDatabase",
"glue:GetTable",
"glue:GetTables",
"glue:GetPartitions",
"glue:GetPartition"
],
"Resource": [
"arn:aws:glue:us-east-1:123456789012:catalog",
"arn:aws:glue:us-east-1:123456789012:database/analytics_lake",
"arn:aws:glue:us-east-1:123456789012:table/analytics_lake/*"
]
}
]
}
Associate the role with the cluster or Serverless namespace before running the CREATE EXTERNAL SCHEMA command. For provisioned clusters, attach via the console or ModifyClusterIamRoles; for Serverless, include the role ARN in CreateNamespaceCommand.iamRoles[].
Creating an external schema pointing to Glue Data Catalog
An external schema in Redshift is a named reference to a Glue Data Catalog database. All tables in that Glue database become queryable through the schema name. Run this DDL via the Redshift Data API from an MCP setup tool or directly via the Redshift query editor:
-- Create external schema backed by the Glue catalog
CREATE EXTERNAL SCHEMA spectrum
FROM DATA CATALOG
DATABASE 'analytics_lake' -- Glue database name
IAM_ROLE 'arn:aws:iam::123456789012:role/RedshiftSpectrumRole'
REGION 'us-east-1' -- Region where the Glue catalog lives
CREATE EXTERNAL DATABASE IF NOT EXISTS; -- Creates the Glue DB if absent
The CREATE EXTERNAL DATABASE IF NOT EXISTS clause is optional but convenient — it creates the Glue database if it doesn't exist yet, so you can bootstrap the full setup in a single DDL statement. Without it, the Glue database must already exist or the command fails.
After creation, spectrum appears in Redshift's schema list alongside public. Query it like any other schema: SELECT * FROM spectrum.my_table. Views and stored procedures in Redshift can reference external tables in Spectrum schemas.
Defining external tables
External tables can be created from Redshift's side or from the Glue catalog side (e.g., via a Glue Crawler or manual table definition in the Glue console/API). Both approaches produce tables visible in the Spectrum schema. Creating from Redshift:
-- External table over Parquet files partitioned by year/month/day
CREATE EXTERNAL TABLE spectrum.events (
event_id VARCHAR(36),
user_id VARCHAR(36),
event_type VARCHAR(64),
properties SUPER, -- JSON object as SUPER type (Redshift native semi-structured)
revenue_usd DECIMAL(12, 4),
event_at TIMESTAMP
)
PARTITIONED BY (dt DATE) -- partition column not in the data files
STORED AS PARQUET
LOCATION 's3://my-data-lake-bucket/events/'
TABLE PROPERTIES ('parquet.compress' = 'SNAPPY');
-- Add partition metadata — must be done for each partition
-- (use partition projection to avoid this for time-series data)
ALTER TABLE spectrum.events ADD PARTITION (dt = '2026-11-01')
LOCATION 's3://my-data-lake-bucket/events/dt=2026-11-01/';
ALTER TABLE spectrum.events ADD PARTITION (dt = '2026-11-02')
LOCATION 's3://my-data-lake-bucket/events/dt=2026-11-02/';
The SUPER type is Redshift's semi-structured data type for JSON objects. It supports dot-notation access (properties.user_agent), array indexing, and JSON_PARSE(). External tables can store JSON columns as SUPER, which Spectrum deserializes at query time — useful for event log data where the schema evolves.
File format support and performance comparison
Spectrum supports many file formats, but performance varies significantly. Choose your format at data-lake design time — changing later requires re-writing all existing files.
| Format | Compression | Column pruning | Predicate pushdown | Best for |
|---|---|---|---|---|
| Parquet | Snappy, GZIP, ZSTD | Yes — column chunks | Yes — min/max row group stats | Analytics workloads, recommended default |
| ORC | Zlib, Snappy | Yes — column stripes | Yes — column-level bloom filters | Hive-compatible data lakes |
| JSON (plain text) | GZIP, BZ2 | No | No | Raw ingest before transformation to Parquet |
| CSV / TSV | GZIP, BZ2 | No | No | Simple exports, legacy compatibility |
| Ion | Binary Ion | Yes | Yes | Amazon-native semi-structured data |
| Avro | Snappy, Deflate | No | No | Schema evolution use cases |
For MCP tools that query large event datasets, Parquet with Snappy compression is the right choice: Spectrum scans only the columns referenced in the SELECT list (skipping others entirely at the S3 layer) and uses row-group min/max statistics to skip large blocks that don't match your WHERE predicate. A query like SELECT event_type, COUNT(*) FROM spectrum.events WHERE dt = '2026-11-01' on a Parquet table may scan only 1–5% of the data that the equivalent JSON query scans.
Partition projection — eliminate manual partition management
The standard ALTER TABLE ... ADD PARTITION approach requires you to manually register each new partition with the Glue catalog. For daily-partitioned tables, that means a daily Lambda running ADD PARTITION before Spectrum can query that day's data. Miss a day, and queries silently return no results for that partition.
Partition projection solves this by instructing Redshift to compute which partitions exist based on a range specification, rather than looking them up in the Glue catalog. No manual partition registration required:
-- External table with partition projection on a date column
CREATE EXTERNAL TABLE spectrum.events_projected (
event_id VARCHAR(36),
user_id VARCHAR(36),
event_type VARCHAR(64),
revenue_usd DECIMAL(12, 4),
event_at TIMESTAMP
)
PARTITIONED BY (dt VARCHAR(10)) -- partition column type must be VARCHAR for date ranges
STORED AS PARQUET
LOCATION 's3://my-data-lake-bucket/events/'
TABLE PROPERTIES (
'projection.enabled' = 'true',
'projection.dt.type' = 'date',
'projection.dt.format' = 'yyyy-MM-dd',
'projection.dt.range' = '2024-01-01,NOW', -- NOW is a dynamic upper bound
'projection.dt.interval' = '1',
'projection.dt.interval.unit' = 'DAYS',
'storage.location.template' = 's3://my-data-lake-bucket/events/dt=${dt}/'
);
With projection.enabled = 'true' and projection.dt.range = '2024-01-01,NOW', Spectrum automatically knows that any date between 2024-01-01 and today is a valid partition. Queries with WHERE dt = '2026-11-12' map directly to s3://my-data-lake-bucket/events/dt=2026-11-12/ without a Glue catalog lookup. If that S3 prefix has no files, the query returns zero rows — no error, no need to manage missing partitions.
Partition projection is especially important for tables with high partition counts (thousands of daily partitions over multi-year datasets). The Glue catalog has a default limit of 1 million partitions per table per account; with projection, the catalog holds zero partition records regardless of how many partitions exist in S3.
Lake Formation integration and column-level security
When Lake Formation governs the Glue Data Catalog, Spectrum queries run through Lake Formation permission checks. The Spectrum IAM role must be granted access in Lake Formation in addition to having S3 and Glue IAM permissions:
import { LakeFormationClient, GrantPermissionsCommand } from "@aws-sdk/client-lakeformation";
const lf = new LakeFormationClient({ region: "us-east-1" });
// Grant SELECT on specific table columns to the Spectrum role
await lf.send(new GrantPermissionsCommand({
Principal: { DataLakePrincipalIdentifier: "arn:aws:iam::123456789012:role/RedshiftSpectrumRole" },
Resource: {
TableWithColumns: {
CatalogId: "123456789012",
DatabaseName: "analytics_lake",
Name: "events",
ColumnWildcard: {
ExcludedColumnNames: ["pii_email", "pii_phone"], // block PII columns
},
},
},
Permissions: ["SELECT"],
}));
Column-level Lake Formation restrictions are enforced at query execution time. If the Spectrum role lacks permission on a column that your SQL references, the query fails with an access denied error — the column is not silently excluded or nulled out. Design MCP tool queries to reference only the columns explicitly needed, and test column permissions after any Lake Formation policy changes.
Query cost and optimization
Spectrum charges $5 per terabyte of S3 data scanned, billed at a minimum of 10 MB per query. The practical cost optimization strategies:
- Always filter on partition columns:
WHERE dt BETWEEN '2026-11-01' AND '2026-11-07'limits scanning to 7 days of data. Without a partition filter, Spectrum scans all partitions. - Use Parquet column pruning:
SELECT event_type, revenue_usd FROM spectrum.eventsonly reads those two Parquet column chunks, not the entire file. AvoidSELECT *on wide tables. - Compress files to reduce scan bytes: GZIP-compressed Parquet reduces bytes scanned (and thus cost) by 60–80% vs uncompressed. Snappy is faster to decompress with slightly worse compression ratio.
- Right-size file size: Spectrum performs best on files between 128 MB and 1 GB. Many small files (under 1 MB) cause excessive S3 API overhead; a single 100 GB file limits parallelism. Use S3 compaction to merge small files regularly.
- Push heavy predicates to Redshift tables: Join a Spectrum external table with a small Redshift-native dimension table — Redshift executes the join with the Spectrum data as the large outer table. Never the reverse; don't join Redshift tables as the outer loop over Spectrum.
Monitor scan costs per query using the SVL_S3QUERY_SUMMARY system view after executing queries directly in the cluster (not via Data API, which doesn't expose query monitoring views):
SELECT
query,
segments,
total_partitions,
qualified_partitions, -- partitions matching your WHERE filters
s3_scanned_bytes, -- bytes actually scanned (what you're billed for)
s3_scanned_rows
FROM SVL_S3QUERY_SUMMARY
ORDER BY starttime DESC
LIMIT 20;
Limitations for MCP tool design
Key Spectrum limitations that affect how you design MCP tools:
- Read-only: Spectrum external tables are read-only. INSERT, UPDATE, DELETE, and MERGE are not supported on external tables. For write operations, use Redshift-native tables or the UNLOAD command to write query results to S3.
- No transactions: External tables don't participate in Redshift transactions. COMMIT and ROLLBACK have no effect on external table operations.
- No cross-schema CTEs in some versions: CTEs that mix Spectrum schemas and Redshift-native schemas work in recent Redshift versions but can fail on older cluster versions. Test on your target cluster version.
- SUPER type not supported in external tables on all Glue types: SUPER works for Redshift-native tables. For Glue-registered tables with JSON columns, use VARCHAR and cast within the query.
- Cluster must be in same region as S3 bucket: Cross-region Spectrum queries are not supported. Use S3 replication to bring data to the same region as the cluster.
Related guides
- Amazon Redshift for MCP servers: Data API basics, IAM auth, async execution
- Redshift Serverless: namespaces, workgroups, RPU configuration, cold starts
- Redshift Data API pagination: NextToken, column metadata, type conversion
- Redshift COPY command: bulk-load S3 data into Redshift from MCP tools
- AWS Glue Data Catalog for MCP tools: databases, tables, crawlers
- MCP server uptime monitoring