lanyard-mcp-server
Provides Discord user presence information through the Lanyard API, enabling AI assistants to retrieve real-time presence data like online status, Spotify activity, and custom KV data.
README
Lanyard MCP Server
A Model Context Protocol (MCP) server that provides Discord user presence information through the Lanyard API.
Purpose
This MCP server provides a secure interface for AI assistants to retrieve real-time Discord presence data, including online status, Spotify activity, Discord activities, and custom KV data for Discord users via the Lanyard service.
Features
Current Implementation
get_user_presence- Get complete Discord presence information including status, platform info, Spotify, activities, and KV dataget_user_spotify- Get detailed Spotify listening information with track details and timestampsget_user_kv- Retrieve custom Lanyard KV (key-value) data set by the user
All tools include:
- Input sanitization and validation for Discord user IDs
- Formatted, human-readable output with emojis
- Proper error handling for API failures
- Rate limit detection
- Timeout handling
Prerequisites
- Docker Desktop with MCP Toolkit enabled
- Docker MCP CLI plugin (
docker mcpcommand) - Discord user IDs (17-20 digit numbers) of users who are using Lanyard
Installation
Step 1: Build the Docker Image
docker build -t lanyard-mcp-server:latest .
Step 2: Configure MCP Catalog
Copy the custom catalog configuration:
# Copy custom.yaml to your Docker MCP catalogs directory
cp custom.yaml ~/.docker/mcp/catalogs/custom.yaml
Step 3: VS Code Integration (Optional)
If using Visual Studio Code with MCP support:
# Copy the MCP configuration to your project
cp .vscode/mcp.json /path/to/your/project/.vscode/
Step 4: Import and Enable the Server
# Import the catalog
docker mcp catalog import custom.yaml
# Enable the Lanyard server
docker mcp server enable lanyard
Agent Prompts
When working with AI agents that have access to this MCP server, you can use these example commands:
Get User Presence Information
docker mcp tools call get_user_presence user_id=77488778255540224
Get Spotify Activity
docker mcp tools call get_user_spotify user_id=77488778255540224
Get Custom KV Data
docker mcp tools call get_user_kv user_id=77488778255540224
Usage Examples
In Claude Desktop, you can ask:
- "What is the Discord presence for user 77488778255540224?"
- "Is user 77488778255540224 listening to Spotify?"
- "Show me the custom KV data for Discord user 77488778255540224"
- "Get the current status and activities for user 77488778255540224"
- "What song is user 77488778255540224 listening to on Spotify?"
What is Lanyard?
Lanyard is a service that exposes Discord user presence data through a REST API and WebSocket. Users must opt-in by joining the Lanyard Discord server. This MCP server uses the REST API to fetch user presence information.
Architecture
AI Agent → MCP Gateway → Lanyard MCP Server → Lanyard API ↓ Discord Presence Data
Development
Local Testing
# Run directly
python lanyard_server.py
# Test MCP protocol
echo '{"jsonrpc":"2.0","method":"tools/list","id":1}' | python lanyard_server.py
# Test with a known user ID (Lanyard creator)
echo '{"jsonrpc":"2.0","method":"tools/call","params":{"name":"get_user_presence","arguments":{"user_id":"94490510688792576"}},"id":2}' | python lanyard_server.py
Adding New Tools
- Add the function to lanyard_server.py
- Decorate with @mcp.tool()
- Follow the pattern: single-line docstring, empty string defaults, return formatted string
- Update the catalog entry with the new tool name
- Rebuild the Docker image
Troubleshooting
Tools Not Appearing
- Verify Docker image built successfully:
docker images | grep lanyard - Check catalog and registry files in
~/.docker/mcp/catalogs/ - Ensure Claude Desktop config includes custom catalog
- Restart Claude Desktop completely
"User not found" Errors
- Verify the Discord user ID is correct (17-20 digits)
- Ensure the user has joined the Lanyard Discord server
- Check that the user hasn't opted out of Lanyard
Rate Limit Errors
- Lanyard API has rate limits
- Wait a few moments before retrying
- Consider implementing caching if making frequent requests
API Reference
This server uses the Lanyard REST API:
- Base URL: https://api.lanyard.rest/v1
- Endpoint: GET /users/:user_id
- Documentation: https://github.com/Phineas/lanyard
Security Considerations
- No authentication required (Lanyard API is public)
- User IDs are validated and sanitized before use
- Running as non-root user in Docker
- Request timeouts prevent hanging
- No sensitive data stored or logged
Future Enhancement Ideas
- WebSocket support for real-time updates
- Caching to reduce API calls
- Batch user lookups
- Historical presence tracking
- Activity statistics
- Custom formatting options
Testing
94490510688792576 - Phineas (Lanyard creator) 77488778255540224 - b6d (MCP integration)
Find more users by joining the Lanyard Discord server.
Limitations
- Requires users to opt-in by joining Lanyard Discord
- Subject to Lanyard API rate limits
- No real-time updates (REST only, not WebSocket)
- Presence data depends on Discord API availability
Resources
- Lanyard GitHub: https://github.com/Phineas/lanyard
- Lanyard Discord: https://discord.gg/lanyard
- MCP Documentation: https://modelcontextprotocol.io
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。