Skip to content

Instantly share code, notes, and snippets.

@chrishow
Created April 8, 2025 18:13
Show Gist options
  • Save chrishow/51874389b456eb40807d4fcef95a1a15 to your computer and use it in GitHub Desktop.
Save chrishow/51874389b456eb40807d4fcef95a1a15 to your computer and use it in GitHub Desktop.
This script compiles a set of Salesforce MCP template files into a JSON object for export, suitable for the clipboard-based import into MCP.
#!/usr/bin/env php
<?php
/*
* This script compiles a set of MCP template files into a JSON object for export.
* It reads the content of each file and adds it to the JSON object.
* The output is printed to the console, you can pipe it to pbcopy then paste it
* into the MCP template editor
*
*/
$files = [
'template.hbs',
'template.css',
'template.js',
'template.ts',
];
$data = new stdClass();
$exportFile = 'export.json';
// Set up basics
$data->description = "Imported template";
$data->public = false;
$data->files = new stdClass();
foreach($files as $file) {
$filePath = __DIR__ . '/' . $file;
if (!file_exists($filePath)) {
echo "File not found: $filePath\n";
continue;
}
// Read the file content
$content = file_get_contents($filePath);
if ($content === false) {
echo "Failed to read file: $filePath\n";
continue;
}
// Add the content to the data object
$contentObj = new stdClass();
$contentObj->content = $content;
$data->files->$file = $contentObj;
}
echo json_encode($data) . "\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment