What are MCP Servers?
MCP Servers are remote services that provide additional tools to your agent using the Model Context Protocol (MCP). Instead of building every tool from scratch, you can connect to existing MCP servers that provide database queries, web searches, documentation access, and more.Think of it as:
Plug-and-play extensions for your agent - connect to pre-built tools without writing code
What is MCP? The Model Context Protocol is an open standard developed by Anthropic for connecting AI models to external tools and data sources. Learn more at modelcontextprotocol.io.
Why MCP Servers?
No Code Required
Use existing MCP servers - just configure and connect
Open Standard
MCP is an open protocol with a growing ecosystem
Extend Capabilities
Add databases, web search, documentation access, and more
Mix & Match
Combine MCP servers with your custom LuaSkills
How MCP Servers Work
Transport Types
MCP servers connect via HTTP-based transports:- Streamable HTTP (Recommended)
- SSE (Legacy)
Modern MCP standard - Best for most use cases
- Single endpoint for bidirectional communication
- Supports session management and resumability
- Works with all modern MCP servers
Simple Example
Common Use Cases
- Documentation
- APIs
- Databases
- Search
Access documentation and knowledge basesTools provided vary by server:
search_docs- Search documentationget_page- Get specific page contentlist_sections- Browse documentation structure
Environment Variables
MCP servers often need API keys or connection strings. Use theenv() function to securely access environment variables at runtime:
- Using env() (Recommended)
- Static Values
Resolved at runtime from agent’s environment
- Function is compiled and executed at runtime
- Values come from
lua env productionsettings - Consistent with
env()in tool execute functions - Recommended for secrets and API keys
Setting Environment Variables: Use
lua env production to manage your agent’s environment variables. These are securely stored and made available to the env() function at runtime.Dynamic URL with env()
You can also useenv() to resolve the URL at runtime:
MCP vs Custom Skills
| Aspect | MCP Servers | LuaSkill |
|---|---|---|
| Code Required | None (just config) | Yes (TypeScript) |
| Customization | Limited to server options | Full control |
| Availability | Growing ecosystem | Unlimited |
| Best For | Standard integrations | Custom business logic |
Best practice: Use MCP servers for standard integrations (docs, APIs, databases) and LuaSkill for custom business logic. They work great together!
Lifecycle
MCP servers have a simple lifecycle:1. Define
1. Define
Create
LuaMCPServer in your source code2. Compile
2. Compile
Run
lua compile - registers server and gets ID3. Push
3. Push
Run
lua push mcp or lua push all --force - syncs configuration4. Activate
4. Activate
Run
lua mcp activate - makes tools available to agent5. Use
5. Use
Agent discovers and uses MCP server tools at runtime
6. Deactivate
6. Deactivate
Run
lua mcp deactivate - removes tools from agentManaging MCP Servers
Use thelua mcp command to manage servers:

