@boostyourleads/mcp-server 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +119 -0
  2. package/package.json +24 -0
package/dist/index.js ADDED
@@ -0,0 +1,119 @@
1
+ #!/usr/bin/env node
2
+ import { Server } from '@modelcontextprotocol/sdk/server/index.js';
3
+ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
4
+ import { CallToolRequestSchema, ListToolsRequestSchema } from '@modelcontextprotocol/sdk/types.js';
5
+ import axios from 'axios';
6
+ const BACKEND_URL = process.env.BYL_BACKEND_URL || 'https://back-end.boostyourleads.ca';
7
+ const API_KEY = process.env.BYL_API_KEY;
8
+ if (!API_KEY) {
9
+ console.error('Error: BYL_API_KEY environment variable is required.');
10
+ process.exit(1);
11
+ }
12
+ const server = new Server({
13
+ name: 'boostyourleads-mcp-server',
14
+ version: '1.0.0'
15
+ }, {
16
+ capabilities: {
17
+ tools: {}
18
+ }
19
+ });
20
+ server.setRequestHandler(ListToolsRequestSchema, async () => {
21
+ return {
22
+ tools: [
23
+ {
24
+ name: 'audit_revenue_integrity',
25
+ description: 'Queries live metrics across channels (Google, Meta, HubSpot, Microsoft, TikTok, Reddit), evaluates discrepancies, checks actual clicks, and returns spend/revenue correction data.',
26
+ inputSchema: {
27
+ type: 'object',
28
+ properties: {
29
+ startDate: { type: 'string', description: 'Start date for comparison (YYYY-MM-DD)' },
30
+ endDate: { type: 'string', description: 'End date for comparison (YYYY-MM-DD)' }
31
+ }
32
+ }
33
+ },
34
+ {
35
+ name: 'optimize_budgets',
36
+ description: 'Analyzes CPL performance drift across all active advertising channels and suggests budget reallocation shifts.',
37
+ inputSchema: {
38
+ type: 'object',
39
+ properties: {}
40
+ }
41
+ },
42
+ {
43
+ name: 'list_google_campaigns',
44
+ description: 'Fetches campaign details (name, status, spend, conversions) from the connected Google Ads profile.',
45
+ inputSchema: {
46
+ type: 'object',
47
+ properties: {}
48
+ }
49
+ },
50
+ {
51
+ name: 'list_meta_creatives',
52
+ description: 'Queries Meta Graph API to fetch active ads, their creative specifications, and performance insights (CTR, ROAS, spend).',
53
+ inputSchema: {
54
+ type: 'object',
55
+ properties: {
56
+ campaignId: { type: 'string', description: 'Filter by specific campaign ID' },
57
+ startDate: { type: 'string', description: 'Start date filter' },
58
+ endDate: { type: 'string', description: 'End date filter' }
59
+ }
60
+ }
61
+ }
62
+ ]
63
+ };
64
+ });
65
+ server.setRequestHandler(CallToolRequestSchema, async (request) => {
66
+ const { name, arguments: args } = request.params;
67
+ const headers = {
68
+ 'Authorization': `Bearer ${API_KEY}`,
69
+ 'Content-Type': 'application/json'
70
+ };
71
+ try {
72
+ if (name === 'audit_revenue_integrity') {
73
+ const res = await axios.post(`${BACKEND_URL}/api/agent/revenue-integrity`, args || {}, { headers });
74
+ return {
75
+ content: [{ type: 'text', text: JSON.stringify(res.data, null, 2) }]
76
+ };
77
+ }
78
+ else if (name === 'optimize_budgets') {
79
+ const res = await axios.post(`${BACKEND_URL}/api/agent/budget-optimizer`, {}, { headers });
80
+ return {
81
+ content: [{ type: 'text', text: JSON.stringify(res.data, null, 2) }]
82
+ };
83
+ }
84
+ else if (name === 'list_google_campaigns') {
85
+ const res = await axios.get(`${BACKEND_URL}/api/google-ads/campaigns`, { headers });
86
+ return {
87
+ content: [{ type: 'text', text: JSON.stringify(res.data, null, 2) }]
88
+ };
89
+ }
90
+ else if (name === 'list_meta_creatives') {
91
+ const res = await axios.get(`${BACKEND_URL}/api/meta-ads/creatives`, {
92
+ params: args,
93
+ headers
94
+ });
95
+ return {
96
+ content: [{ type: 'text', text: JSON.stringify(res.data, null, 2) }]
97
+ };
98
+ }
99
+ else {
100
+ throw new Error(`Tool not found: ${name}`);
101
+ }
102
+ }
103
+ catch (err) {
104
+ const errorMsg = err.response?.data?.error || err.message;
105
+ return {
106
+ isError: true,
107
+ content: [{ type: 'text', text: `Failed to execute tool ${name}: ${errorMsg}` }]
108
+ };
109
+ }
110
+ });
111
+ async function main() {
112
+ const transport = new StdioServerTransport();
113
+ await server.connect(transport);
114
+ console.error('BoostYourLeads MCP Server running on stdio');
115
+ }
116
+ main().catch((error) => {
117
+ console.error('Error running MCP server:', error);
118
+ process.exit(1);
119
+ });
package/package.json ADDED
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "@boostyourleads/mcp-server",
3
+ "version": "1.0.0",
4
+ "description": "BoostYourLeads Model Context Protocol Server",
5
+ "main": "dist/index.js",
6
+ "type": "module",
7
+ "bin": {
8
+ "byl-mcp-server": "dist/index.js"
9
+ },
10
+ "files": [
11
+ "dist"
12
+ ],
13
+ "scripts": {
14
+ "build": "tsc"
15
+ },
16
+ "dependencies": {
17
+ "@modelcontextprotocol/sdk": "^1.0.1",
18
+ "axios": "^1.6.0"
19
+ },
20
+ "devDependencies": {
21
+ "@types/node": "^20.0.0",
22
+ "typescript": "^5.0.0"
23
+ }
24
+ }