Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .vscode/mcp.json
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The file is in .gitignore, but I pushed the default configuration

Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"servers": {
"plainly": {
"command": "yarn",
"args": [
"dlx",
"@plainly-videos/mcp-server@latest",
"mcp-server"
],
"env": {
"PLAINLY_API_KEY": "<PLAINLY_API_KEY>"
}
}
}
}
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ Implementation of MCP server for [Plainly](https://www.plainlyvideos.com/) in No
{
"servers": {
"plainly": {
"command": "npx",
"args": ["-y", "@plainly-videos/mcp-server@latest"],
"command": "yarn",
"args": ["dlx", "@plainly-videos/mcp-server@latest", "mcp-server"],
"env": {
"PLAINLY_API_KEY": "<PLAINLY_API_KEY>"
}
Expand Down
11 changes: 9 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@plainly-videos/mcp-server",
"version": "1.0.0",
"version": "1.0.1",
"description": "MCP server for Plainly Videos that allows browsing designs and projects, as well as rendering videos.",
"license": "MIT",
"author": "PlainlyVideos <contact@planlyvideos.com>",
Expand All @@ -19,8 +19,15 @@
"mcp-server",
"modelcontextprotocol",
"aftereffects",
"adobe-after-effects",
"video-api",
"video-automation"
"video-automation",
"video-processing",
"video-rendering",
"automation",
"api",
"javascript",
"typescript"
],
"bin": "dist/index.js",
"files": [
Expand Down
3 changes: 2 additions & 1 deletion src/axiosConfig.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import axios, { AxiosInstance } from "axios";
import env from "./env";
import { PACKAGE_NAME, PACKAGE_VERSION } from "./contants";

export function createAxiosInstance(config?: {
baseUrl?: string;
Expand All @@ -15,7 +16,7 @@ export function createAxiosInstance(config?: {
password: "",
},
headers: {
"User-Agent": "plainly-mcp-server/1.0",
"User-Agent": `${PACKAGE_NAME}/${PACKAGE_VERSION}`,
},
timeout: 10000,
});
Expand Down
4 changes: 4 additions & 0 deletions src/contants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { name, version } from "../package.json";

export const PACKAGE_NAME = name;
export const PACKAGE_VERSION = version;
13 changes: 9 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,18 @@

import { PlainlyMcpServer } from "./server";
import env from "./env";
import { isValidApiKey } from "./sdk";

// Validate required environment variables
if (!env.PLAINLY_API_KEY || !env.PLAINLY_API_URL) {
console.error(
"Please set PLAINLY_API_KEY and PLAINLY_API_URL environment variables."
);
if (!env.PLAINLY_API_KEY) {
console.error("\nERROR: PLAINLY_API_KEY environment variable is required.\n");
process.exit(1);
} else {
// Test API key
if (!(await isValidApiKey())) {
console.error("\nERROR: Invalid PLAINLY_API_KEY.\n");
process.exit(1);
}
}

const server = new PlainlyMcpServer();
Expand Down
12 changes: 12 additions & 0 deletions src/sdk/api/checkApiKey.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { createAxiosInstance } from "../../axiosConfig";

const api = createAxiosInstance();

export const isValidApiKey = async (): Promise<boolean> => {
try {
await api.get(`/api/v2/me`);
return true;
} catch {
return false;
}
};
1 change: 1 addition & 0 deletions src/sdk/api/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from "./checkApiKey";
export * from "./listRenderableItems";
export * from "./getRenderableItemDetails";
export * from "./renderItem";
Expand Down
6 changes: 2 additions & 4 deletions src/sdk/api/renderItem.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { AxiosResponse } from "axios";
import { createAxiosInstance } from "../../axiosConfig";
import { ProjectRenderDto, Render } from "../types";

// get name from package.json
import { name } from "../../../package.json";
import { PACKAGE_NAME } from "../../contants";

const api = createAxiosInstance();

Expand All @@ -24,7 +22,7 @@ export const renderItem = async (params: RenderParams): Promise<Render> => {
templateId: params.templateVariantId,
parameters: params.parameters,
attributes: {
[name]: "true",
[PACKAGE_NAME]: "true",
},
});

Expand Down
5 changes: 3 additions & 2 deletions src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@ import {
registerRenderItem,
registerCheckRenderStatus,
} from "./tools";
import { PACKAGE_NAME, PACKAGE_VERSION } from "./contants";

export class PlainlyMcpServer {
server: McpServer;
transport: StdioServerTransport;

constructor() {
this.server = new McpServer({
name: "plainly-mcp-server",
version: "1.0.0",
name: PACKAGE_NAME,
version: PACKAGE_VERSION,
});
this.transport = new StdioServerTransport();

Expand Down
Loading