MCP Integration

Connect to 90+ services

🔗 What is MCP?

Model Context Protocol (MCP) is a standard protocol for AI tool integration. Connect to databases, APIs, file systems, and more!

Available Servers:

  • fetch - HTTP requests
  • sqlite, postgres, mysql, mongodb - Databases
  • redis - Cache
  • git, github - Version control
  • filesystem - File operations
  • And 85+ more!

⚙️ Setup and configuration

Create .kiro/settings/mcp.json:

{
  "mcpServers": {
    "fetch": {
      "command": "uvx",
      "args": ["mcp-server-fetch"]
    },
    "sqlite": {
      "command": "uvx",
      "args": ["mcp-server-sqlite", "--db-path", "./data.db"]
    },
    "postgres": {
      "command": "uvx",
      "args": ["mcp-server-postgres"]
    }
  }
}

🌐 HTTP Requests with Fetch

// API call
let github_data = mcp.call("fetch", "fetch", {
    url: "https://api.github.com/repos/hudhud/hudhudscript"
});
print(github_data);

// With agent
agent APIAgent {
    provider: "openai"
    
    task fetch_data(url) {
        let data = mcp.call("fetch", "fetch", {
            url: url
        });
        
        let analysis = this.call({
            prompt: `Analyze this data: ${data}`
        });
        
        return analysis.content;
    }
}

let result = APIAgent.fetch_data("https://api.example.com/data");
print(result);

🗄️ Database Operations

// SQLite
let users = mcp.call("sqlite", "query", {
    sql: "SELECT * FROM users WHERE age > 18"
});
print(users);

// PostgreSQL
let orders = mcp.call("postgres", "query", {
    sql: "SELECT * FROM orders WHERE status = 'pending'"
});
print(orders);

// MongoDB
let documents = mcp.call("mongodb", "find", {
    collection: "products",
    query: { price: { $gt: 100 } }
});
print(documents);

📁 File System Operations

// Read file
let content = mcp.call("filesystem", "read_file", {
    path: "./data.txt"
});
print(content);

// Write file
mcp.call("filesystem", "write_file", {
    path: "./output.txt",
    content: "Hello, World!"
});

// List directory
let files = mcp.call("filesystem", "list_directory", {
    path: "./documents"
});
print(files);

🔄 Git Operations

// Clone repository
mcp.call("git", "clone", {
    url: "https://github.com/user/repo.git",
    path: "./repo"
});

// Commit changes
mcp.call("git", "commit", {
    path: "./repo",
    message: "Update documentation"
});

// Push to remote
mcp.call("git", "push", {
    path: "./repo",
    remote: "origin",
    branch: "main"
});

🚀 Real-World Example

Data pipeline with multiple MCP servers:

agent DataPipeline {
    provider: "openai"
    
    task process() {
        // 1. Fetch data from API
        let raw_data = mcp.call("fetch", "fetch", {
            url: "https://api.example.com/sales"
        });
        
        // 2. Analyze with AI
        let analysis = this.call({
            prompt: `Analyze this sales data: ${raw_data}`
        });
        
        // 3. Store in database
        mcp.call("postgres", "execute", {
            sql: `INSERT INTO reports (data, analysis) 
                  VALUES ($1, $2)`,
            params: [raw_data, analysis.content]
        });
        
        // 4. Save report to file
        mcp.call("filesystem", "write_file", {
            path: "./reports/latest.txt",
            content: analysis.content
        });
        
        // 5. Commit to git
        mcp.call("git", "commit", {
            path: ".",
            message: "Add latest report"
        });
        
        return "Pipeline completed!";
    }
}

let result = DataPipeline.process();
print(result);

🚀 Next Steps

Explore AI Agents and Swarms to build complex systems!