MCP Client - Model Context Protocol
🎯 What is MCP?
🏗️ MCP Client Architecture
🚀 Basic Usage
// Create an MCP client
client = MCP( "http://localhost:3000" )
// Send a request to a tool
result = client.send( "searchDocs", {
query: "BoxLang syntax",
limit: 10
} )
// Check the response
if ( result.getSuccess() ) {
writeOutput( result.getData() )
} else {
writeOutput( "Error: " & result.getError() )
}⚙️ Client Configuration
⏱️ Timeout Configuration
Custom Headers
Authentication
Callbacks
Fluent Chaining
Discovery Methods
List Tools
List Resources
List Prompts
Get Capabilities
Execution Methods
Send Tool Request
Read Resource
Get Prompt
Response Structure
Error Handling
Network Errors
HTTP Errors
Try-Catch Pattern
Real-World Examples
Documentation Search
Integration with AI Chat
Resource Caching
MCP Server Endpoints
Endpoint
Method
Purpose
Request Body
Best Practices
1. Use Configuration Objects
2. Always Check Success
3. Use Callbacks for Observability
4. Timeout Appropriately
5. Secure Credentials
Testing MCP Clients
Unit Testing
Related Documentation
External Resources
Last updated