FastMCP server for Spyglass AI agent
Project description
Spyglass AI MCP Server
The Spyglass AI MCP server provides a simple interface for LLMs to query the Spyglass AI agent. The agent analyzes your telemetry data and provides intelligent insights about application performance, errors, and bottlenecks.
To install the MCP server for Cursor click the button below. It should open Cursor and prompt you to add your API Key.
Alternatively, add the following to your ~/.cursor/mcp.json file (create it if you need to) and substitute your Spyglass API Key. Then restart Cursor to apply the change.
{
"mcpServers": {
"spyglass-ai": {
"command": "uv",
"args": ["run", "spyglass-mcp"],
"env": {
"SPYGLASS_API_KEY": "your-key-here"
}
}
}
}
Note that you need to have uv installed first, see the docs for that here
Available Tools
call_spyglass_agent
Calls the Spyglass AI agent with a natural language query about your telemetry data.
Parameters:
query(string, required): Natural language query about your application's telemetry data
Example queries:
- "What are the slowest endpoints in the last hour?"
- "Show me all errors in the checkout service"
- "Which services have the highest error rate?"
- "What's causing high latency in my API?"
- "How many requests has my app had in the last day?"
Returns:
- Natural language analysis of the telemetry data
Configuration
Environment Variables
| Variable | Required | Default | Description |
|---|---|---|---|
SPYGLASS_API_KEY |
Yes | N/A | API Key for authentication with Spyglass agent |
SPYGLASS_AGENT_ENDPOINT |
No | https://agent.spyglass-ai.com |
Agent endpoint URL (useful for local testing) |
Command Line Arguments
| Argument | Required | Default | Description |
|---|---|---|---|
--endpoint |
No | https://agent.spyglass-ai.com |
Spyglass agent endpoint URL |
--transport |
No | stdio |
Transport type (stdio or http) |
--port |
No | 8000 |
Port for HTTP transport |
Example: Using with an MCP Client
import asyncio
from fastmcp import Client
client = Client("http://localhost:8000/mcp")
async def analyze():
async with client:
result = await client.call_tool("call_spyglass_agent", {
"query": "What are the slowest endpoints?"
})
print(result)
asyncio.run(analyze())
Logging
The MCP server logs to both stderr (captured by Cursor) and a file for debugging:
Log file location:
~/.spyglass/logs/mcp-server-YYYYMMDD.log
View logs in real-time:
tail -f ~/.spyglass/logs/mcp-server-$(date +%Y%m%d).log
The logs include:
- Server startup and configuration
- Incoming queries and responses
- API call details (with truncated tokens for security)
- Error messages and stack traces
Development
Prerequisites
- Python 3.11 or higher
- uv package manager
Setup
- Clone the repository and navigate to the project directory:
cd spyglass-mcp
- Install dependencies:
uv sync
This will create a virtual environment and install all required dependencies.
- Copy the example environment file and configure your API key:
cp env.example .env
# Edit .env and add your SPYGLASS_API_KEY
Running Locally
Run the MCP server in stdio mode (default):
uv run spyglass-mcp
Run with a custom endpoint (useful for testing against a local agent):
uv run spyglass-mcp --endpoint http://localhost:8080
Run in HTTP transport mode:
uv run spyglass-mcp --transport http --port 8000
Running Tests
Run all tests:
uv run pytest
Run tests with verbose output:
uv run pytest -v
Run a specific test file:
uv run pytest tests/test_mcp_server.py
Run tests with coverage:
uv run pytest --cov=spyglass_mcp --cov-report=term-missing
Building
Build the package for distribution:
uv build
This will create wheel and source distribution files in the dist/ directory.
Project Structure
spyglass-mcp/
├── .github/
│ └── workflows/
│ └── publish.yaml
├── src/
│ └── spyglass_mcp/
│ ├── __init__.py
│ └── main.py
├── tests/
│ ├── __init__.py
│ ├── conftest.py
│ └── test_mcp_server.py
├── CHANGELOG.md
├── env.example
├── LICENSE
├── pyproject.toml
├── README.md
└── uv.lock
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file spyglass_mcp-0.1.0.tar.gz.
File metadata
- Download URL: spyglass_mcp-0.1.0.tar.gz
- Upload date:
- Size: 76.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
42cc5b08c497878a2bdd84c19ee07a6a4cd6ebd6cde48d39c9fd2cb80812182c
|
|
| MD5 |
70a9c061dd9912b053cb7371ec252129
|
|
| BLAKE2b-256 |
84ea1007f32850d0ebaa38321655fed5ca6ef1fe45baa0d71e6ac4d9a43de897
|
Provenance
The following attestation bundles were made for spyglass_mcp-0.1.0.tar.gz:
Publisher:
publish.yaml on Spyglass-AI/spyglass-mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
spyglass_mcp-0.1.0.tar.gz -
Subject digest:
42cc5b08c497878a2bdd84c19ee07a6a4cd6ebd6cde48d39c9fd2cb80812182c - Sigstore transparency entry: 631769766
- Sigstore integration time:
-
Permalink:
Spyglass-AI/spyglass-mcp@20d32481f525a530c65873ecb127db4d0647029c -
Branch / Tag:
refs/tags/v0.0.1 - Owner: https://github.com/Spyglass-AI
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@20d32481f525a530c65873ecb127db4d0647029c -
Trigger Event:
push
-
Statement type:
File details
Details for the file spyglass_mcp-0.1.0-py3-none-any.whl.
File metadata
- Download URL: spyglass_mcp-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
93574bb56c221516baadaa933fce7976981cc1c4823bbed84268a85e60a4caa8
|
|
| MD5 |
630a892212157e7e551b9fa1a9ced6dc
|
|
| BLAKE2b-256 |
36ba61159b7d9a16d6ceb0e548efb59712e190df0082533112e250f9874336ac
|
Provenance
The following attestation bundles were made for spyglass_mcp-0.1.0-py3-none-any.whl:
Publisher:
publish.yaml on Spyglass-AI/spyglass-mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
spyglass_mcp-0.1.0-py3-none-any.whl -
Subject digest:
93574bb56c221516baadaa933fce7976981cc1c4823bbed84268a85e60a4caa8 - Sigstore transparency entry: 631769769
- Sigstore integration time:
-
Permalink:
Spyglass-AI/spyglass-mcp@20d32481f525a530c65873ecb127db4d0647029c -
Branch / Tag:
refs/tags/v0.0.1 - Owner: https://github.com/Spyglass-AI
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@20d32481f525a530c65873ecb127db4d0647029c -
Trigger Event:
push
-
Statement type: