A hands-on workshop for building a Model Context Protocol (MCP) server that serves random fortune cookie messages.
The Unix fortune command is a classic utility that displays random quotations, jokes, or sayings - essentially digital "fortune cookies." Fortune files contain collections of quotes separated by % lines.
The Model Context Protocol (MCP) is a standard for connecting AI assistants with external data sources and tools. An MCP server exposes tools and resources that AI models can use to enhance their capabilities.
Build an MCP server that provides fortune cookie functionality to AI assistants. Your server should be able to serve random fortunes from the provided data file.
- Explore the data: Check out
data/fortunes.txtto understand the fortune file format - Choose your language: Implement in Python, TypeScript, Go, Rust, or any language you prefer
- Use AI assistance: Leverage GitHub Copilot, Cursor, or similar tools to help with implementation
- Design your MCP server: Think about what tools/resources your server should expose
A working MCP server that can:
- Read fortune data from the provided file
- Serve random fortunes via MCP protocol
- Be discoverable and usable by MCP clients
- Wikipedia UNIX “fortune” command
- MCP specification
- Use your AI coding assistant to learn MCP server patterns and implementation details
- Fortune data
- The cookie file format is multiline strings seperated by a '%' char
- Past implementations have used a directory with multiple data files with methods for filtering the content
data/fortunes.txt- 3 sample fortunes provided in this repo- classical and historical cookie files
- fortune implementations
- Start simple - get basic fortune serving working first
- Consider what MCP tools would be most useful (random fortune, fortune by keyword, etc.)
- Test your server with an MCP client to ensure it works
- Document your approach and any interesting design decisions
Happy coding! 🥠