AI Automation with MCP
Connect AI agents directly to StarLaker using the Model Context Protocol (MCP). Let Claude, GPT, or any LLM write, schedule, and publish posts — no manual steps.
What is MCP?
The Model Context Protocol lets AI models call external tools — APIs, databases, file systems — through a standardized interface. Think of it as "function calling" that works across different AI platforms.
With a StarLaker MCP server, your AI can:
- Write and publish blog posts
- Generate content on a schedule
- Cross-post to Medium and LinkedIn
- Read analytics and suggest topics
- Manage drafts and publishing queue
1. Create the MCP Server
Create a file called starlaker-mcp.js:
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
const STARLAKER_KEY = process.env.STARLAKER_KEY;
const BASE = "https://starlaker.com/api/v1";
const server = new Server(
{ name: "starlaker-mcp", version: "1.0.0" },
{ capabilities: { tools: {} } }
);
// Tool: Publish a post
server.setRequestHandler("tools/call", async (request) => {
const { name, arguments: args } = request.params;
if (name === "publish_post") {
const res = await fetch(BASE + "/posts", {
method: "POST",
headers: {
"Authorization": "Bearer " + STARLAKER_KEY,
"Content-Type": "application/json",
},
body: JSON.stringify({
title: args.title,
content: args.content,
tags: args.tags || [],
status: args.status || "published",
}),
});
const data = await res.json();
return {
content: [{
type: "text",
text: data.success
? "Published! " + data.url
: "Failed: " + data.error,
}],
};
}
if (name === "list_posts") {
const res = await fetch(BASE + "/posts?limit=10");
const data = await res.json();
return {
content: [{
type: "text",
text: JSON.stringify(data.data, null, 2),
}],
};
}
if (name === "get_analytics") {
// Returns top posts by views
const res = await fetch(BASE + "/posts?limit=50");
const data = await res.json();
const ranked = (data.data || [])
.sort((a, b) => (b.views || 0) - (a.views || 0))
.slice(0, 10);
return {
content: [{
type: "text",
text: JSON.stringify(ranked, null, 2),
}],
};
}
throw new Error("Unknown tool: " + name);
});
// Register tools
server.setRequestHandler("tools/list", async () => ({
tools: [
{
name: "publish_post",
description: "Publish a new post to StarLaker. Returns the post URL on success.",
inputSchema: {
type: "object",
properties: {
title: { type: "string", description: "Post title" },
content: { type: "string", description: "Markdown content" },
tags: { type: "array", items: { type: "string" } },
status: { type: "string", enum: ["draft", "published"] },
},
required: ["title", "content"],
},
},
{
name: "list_posts",
description: "List recent published posts on StarLaker.",
inputSchema: { type: "object", properties: {} },
},
{
name: "get_analytics",
description: "Get top posts by view count for content strategy.",
inputSchema: { type: "object", properties: {} },
},
],
}));
const transport = new StdioServerTransport();
await server.connect(transport);2. Configure in Claude Desktop
Add to ~/.config/claude/claude_desktop_config.json:
{
"mcpServers": {
"starlaker": {
"command": "node",
"args": ["/path/to/starlaker-mcp.js"],
"env": {
"STARLAKER_KEY": "sl_live_your_key_here"
}
}
}
}Restart Claude Desktop. You'll see 🔨 tools appear in the chat.
3. Use It
In Claude Desktop, just ask:
You: Write a blog post about the latest trends in AI engineering and publish it to StarLaker with tags "AI" and "engineering".
Claude: [writes content, calls publish_post tool] Published! https://starlaker.com/post/latest-trends-in-ai-engineering
You: What are my top performing posts? Should I write more about React or AI?
Claude: [calls get_analytics] Your top post has 2,400 views on AI topics. AI content performs 3x better. I suggest writing about AI agent architectures next.
4. VS Code Copilot Setup
Add to VS Code settings (.vscode/settings.json):
{
"mcp": {
"servers": {
"starlaker": {
"command": "node",
"args": ["starlaker-mcp.js"],
"env": {
"STARLAKER_KEY": "sl_live_your_key_here"
}
}
}
}
}5. Scheduled AI Publishing
Combine with a cron job for fully autonomous content:
#!/bin/bash
# ai-publish.sh — runs daily at 9 AM
TOPIC=$(curl -s "https://newsapi.org/v2/top-headlines?category=technology&apiKey=YOUR_KEY" | jq -r '.articles[0].title')
# Ask local LLM to write a post
CONTENT=$(ollama run llama3.2 "Write a markdown blog post about: $TOPIC. Keep it under 500 words.")
# Publish to StarLaker
curl -s -X POST https://starlaker.com/api/v1/posts \
-H "Authorization: Bearer $STARLAKER_KEY" \
-H "Content-Type: application/json" \
-d "{\"title\":\"$TOPIC\",\"content\":\"$CONTENT\",\"tags\":[\"ai-generated\",\"tech\"],\"status\":\"published\"}"
echo "Published: $TOPIC"Add to crontab: 0 9 * * * /path/to/ai-publish.sh
6. Python SDK (Alternative to MCP)
If you prefer Python over MCP, a simple wrapper:
import requests, os
class StarLaker:
def __init__(self):
self.key = os.environ["STARLAKER_KEY"]
self.base = "https://starlaker.com/api/v1"
def publish(self, title, content, tags=None, status="published"):
r = requests.post(f"{self.base}/posts", json={
"title": title, "content": content,
"tags": tags or [], "status": status,
}, headers={"Authorization": f"Bearer {self.key}"})
return r.json()
def list_posts(self, limit=20):
r = requests.get(f"{self.base}/posts", params={"limit": limit})
return r.json()["data"]
sl = StarLaker()
sl.publish("AI Generated", "## Hello from Python", tags=["ai"])Quick Reference
| Method | Best for |
|---|---|
| MCP Server | Claude Desktop, VS Code Copilot — interactive AI publishing |
| Cron + LLM | Fully autonomous daily content generation |
| Python SDK | Custom AI agents, Jupyter notebooks, data pipelines |
| REST API | Any language, any platform — direct HTTP calls |
See also: API Reference — VS Code Setup — Getting Started