Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit f51db6d

Browse files
install prettier and format code
1 parent 89234b5 commit f51db6d

File tree

13 files changed

+175
-145
lines changed

13 files changed

+175
-145
lines changed

‎.prettierignore‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Ignore artifacts:
2+
build
3+
coverage

‎.prettierrc‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

‎README.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
## ZOOM API
2+
23
- [Create Meeting](https://developers.zoom.us/docs/api/meetings/#tag/meetings/POST/users/{userId}/meetings)

‎common/auth.ts‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,24 @@ import { TokenSchema } from "./types.js";
22
import { zoomRequest } from "./util.js";
33

44
export async function getAccessToken() {
5-
let accountId = '';
5+
let accountId = "";
66
if (process.env.ZOOM_ACCOUNT_ID) {
77
accountId = process.env.ZOOM_ACCOUNT_ID;
88
}
99

10-
let authUrl = `https://zoom.us/oauth/token?grant_type=account_credentials&account_id=${accountId}`
10+
let authUrl = `https://zoom.us/oauth/token?grant_type=account_credentials&account_id=${accountId}`;
1111

1212
const key = `Basic ${calculateToken()}`;
1313
const response = await zoomRequest(authUrl, {
1414
method: "POST",
15-
headers: { 'Authorization': key }
15+
headers: { Authorization: key },
1616
});
1717
return TokenSchema.parse(response);
1818
}
1919

2020
function calculateToken(): string {
21-
let clientId = '';
22-
let clientSecret = '';
21+
let clientId = "";
22+
let clientSecret = "";
2323

2424
if (process.env.ZOOM_CLIENT_ID) {
2525
clientId = process.env.ZOOM_CLIENT_ID;
@@ -33,5 +33,5 @@ function calculateToken(): string {
3333

3434
function generateBasicAuth(username: string, password: string): string {
3535
const credentials = `${username}:${password}`;
36-
return Buffer.from(credentials).toString('base64');
37-
}
36+
return Buffer.from(credentials).toString("base64");
37+
}

‎common/error.ts‎

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,30 @@
11
export class ZoomError extends Error {
2-
constructor(
3-
message: string,
4-
public readonly status: number,
5-
public readonly response: unknown
6-
) {
7-
super(message);
8-
this.name = "ZoomError";
9-
}
2+
constructor(
3+
message: string,
4+
public readonly status: number,
5+
public readonly response: unknown,
6+
) {
7+
super(message);
8+
this.name = "ZoomError";
9+
}
1010
}
1111

12-
export class ZoomAuthenticationError extends ZoomError {
13-
constructor(message = "Authentication failed") {
14-
super(message, 401, { message });
15-
this.name = "ZoomAuthenticationError";
16-
}
12+
export class ZoomAuthenticationError extends ZoomError {
13+
constructor(message = "Authentication failed") {
14+
super(message, 401, { message });
15+
this.name = "ZoomAuthenticationError";
16+
}
1717
}
1818

19-
2019
export function createZoomError(status: number, response: any): ZoomError {
21-
switch (status) {
22-
case 401:
23-
return new ZoomAuthenticationError(response?.message);
24-
default:
25-
return new ZoomError(
26-
response?.message || "Zoom API error",
27-
status,
28-
response
29-
);
30-
}
31-
}
20+
switch (status) {
21+
case 401:
22+
return new ZoomAuthenticationError(response?.message);
23+
default:
24+
return new ZoomError(
25+
response?.message || "Zoom API error",
26+
status,
27+
response,
28+
);
29+
}
30+
}

‎common/types.ts‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { z } from "zod";
22

33
export const TokenSchema = z.object({
4-
access_token: z.string(),
5-
token_type: z.string(),
6-
expires_in: z.number(),
7-
scope: z.string(),
8-
api_url: z.string()
9-
});
4+
access_token: z.string(),
5+
token_type: z.string(),
6+
expires_in: z.number(),
7+
scope: z.string(),
8+
api_url: z.string(),
9+
});
1010

1111
export const ZoomMeetingSchema = z.object({
12-
uuid: z.string()
13-
});
12+
uuid: z.string(),
13+
});

‎common/util.ts‎

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3,42 +3,42 @@ import { VERSION } from "./version.js";
33
import { createZoomError } from "./error.js";
44

55
type RequestOptions = {
6-
method?: string;
7-
body?: unknown;
8-
headers?: Record<string, string>;
9-
}
6+
method?: string;
7+
body?: unknown;
8+
headers?: Record<string, string>;
9+
};
1010

1111
async function parseResponseBody(response: Response): Promise<unknown> {
12-
const contentType = response.headers.get("content-type");
13-
if (contentType?.includes("application/json")) {
14-
return response.json();
15-
}
16-
return response.text();
12+
const contentType = response.headers.get("content-type");
13+
if (contentType?.includes("application/json")) {
14+
return response.json();
15+
}
16+
return response.text();
1717
}
1818

1919
const USER_AGENT = `zoom-mcp-server/v${VERSION} ${getUserAgent()}`;
2020

2121
export async function zoomRequest(
22-
url: string,
23-
options: RequestOptions = {}
22+
url: string,
23+
options: RequestOptions = {},
2424
): Promise<unknown> {
25-
const headers: Record<string, string> = {
26-
"Content-Type": "application/json",
27-
"User-Agent": USER_AGENT,
28-
...options.headers,
29-
};
30-
31-
const response = await fetch(url, {
32-
method: options.method || "GET",
33-
headers,
34-
body: options.body ? JSON.stringify(options.body) : undefined,
35-
});
36-
37-
const responseBody = await parseResponseBody(response);
38-
39-
if (!response.ok) {
40-
throw createZoomError(response.status, responseBody);
41-
}
42-
43-
return responseBody;
44-
}
25+
const headers: Record<string, string> = {
26+
"Content-Type": "application/json",
27+
"User-Agent": USER_AGENT,
28+
...options.headers,
29+
};
30+
31+
const response = await fetch(url, {
32+
method: options.method || "GET",
33+
headers,
34+
body: options.body ? JSON.stringify(options.body) : undefined,
35+
});
36+
37+
const responseBody = await parseResponseBody(response);
38+
39+
if (!response.ok) {
40+
throw createZoomError(response.status, responseBody);
41+
}
42+
43+
return responseBody;
44+
}

‎common/version.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export const VERSION = "0.1";
1+
export const VERSION = "0.1";

‎index.ts‎

Lines changed: 51 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -2,68 +2,74 @@
22
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
33
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
44
import { VERSION } from "./common/version.js";
5-
import { CallToolRequestSchema, ListToolsRequestSchema } from "@modelcontextprotocol/sdk/types.js";
6-
import { zodToJsonSchema } from 'zod-to-json-schema';
7-
import { createMeeting, CreateMeetingOptionsSchema } from "./operations/meeting.js";
5+
import {
6+
CallToolRequestSchema,
7+
ListToolsRequestSchema,
8+
} from "@modelcontextprotocol/sdk/types.js";
9+
import { zodToJsonSchema } from "zod-to-json-schema";
10+
import {
11+
createMeeting,
12+
CreateMeetingOptionsSchema,
13+
} from "./operations/meeting.js";
814
import { z } from "zod";
915
import { getAccessToken } from "./common/auth.js";
1016

1117
const server = new Server(
12-
{
13-
name: 'zoom-mcp-server',
14-
version: VERSION,
15-
}, {
18+
{
19+
name: "zoom-mcp-server",
20+
version: VERSION,
21+
},
22+
{
1623
capabilities: {
17-
tools: {},
24+
tools: {},
1825
},
19-
}
26+
},
2027
);
2128

2229
server.setRequestHandler(ListToolsRequestSchema, async () => {
23-
return {
24-
tools: [
25-
{
26-
name: "create_meeting",
27-
description: "Create a meeting",
28-
inputSchema: zodToJsonSchema(CreateMeetingOptionsSchema),
29-
}
30-
]
31-
}
30+
return {
31+
tools: [
32+
{
33+
name: "create_meeting",
34+
description: "Create a meeting",
35+
inputSchema: zodToJsonSchema(CreateMeetingOptionsSchema),
36+
},
37+
],
38+
};
3239
});
3340

3441
server.setRequestHandler(CallToolRequestSchema, async (request) => {
35-
try {
36-
if (!request.params.arguments) {
37-
throw new Error("No arguments provided");
38-
}
39-
let token = await getAccessToken();
40-
switch (request.params.name) {
41-
case "create_meeting": {
42-
const args = CreateMeetingOptionsSchema.parse(request.params.arguments);
43-
const result = await createMeeting(args, token.access_token);
44-
return {
45-
content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
46-
};
47-
}
48-
}
49-
50-
} catch (error) {
51-
if (error instanceof z.ZodError) {
52-
throw new Error(`Invalid input: ${JSON.stringify(error.errors)}`);
53-
}
54-
throw error;
42+
try {
43+
if (!request.params.arguments) {
44+
throw new Error("No arguments provided");
5545
}
46+
let token = await getAccessToken();
47+
switch (request.params.name) {
48+
case "create_meeting": {
49+
const args = CreateMeetingOptionsSchema.parse(request.params.arguments);
50+
const result = await createMeeting(args, token.access_token);
51+
return {
52+
content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
53+
};
54+
}
55+
}
56+
} catch (error) {
57+
if (error instanceof z.ZodError) {
58+
throw new Error(`Invalid input: ${JSON.stringify(error.errors)}`);
59+
}
60+
throw error;
61+
}
5662

57-
return {};
63+
return {};
5864
});
5965

6066
async function runServer() {
61-
const transport = new StdioServerTransport();
62-
await server.connect(transport);
63-
console.log("zoom mcp server running on stdio")
67+
const transport = new StdioServerTransport();
68+
await server.connect(transport);
69+
console.log("zoom mcp server running on stdio");
6470
}
6571

6672
runServer().catch((error) => {
67-
console.error("Fatal error in main()", error);
68-
process.exit(1);
69-
});
73+
console.error("Fatal error in main()", error);
74+
process.exit(1);
75+
});

‎operations/meeting.ts‎

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,23 @@ import { zoomRequest } from "../common/util.js";
33
import { ZoomMeetingSchema } from "../common/types.js";
44

55
export const CreateMeetingOptionsSchema = z.object({
6-
agenda: z.string().describe("Meeting name"),
7-
startTime: z.string().optional().describe("Meeting start time")
8-
})
6+
agenda: z.string().describe("Meeting name"),
7+
startTime: z.string().optional().describe("Meeting start time"),
8+
});
99

1010
export type CreateMeetingOptions = z.infer<typeof CreateMeetingOptionsSchema>;
1111

12-
export async function createMeeting(options: CreateMeetingOptions, token: string) {
13-
const response = await zoomRequest(`https://api.zoom.us/v2/users/me/meetings`, {
12+
export async function createMeeting(
13+
options: CreateMeetingOptions,
14+
token: string,
15+
) {
16+
const response = await zoomRequest(
17+
`https://api.zoom.us/v2/users/me/meetings`,
18+
{
1419
method: "POST",
1520
body: options,
16-
headers: { 'Authorization': `Bearer ${token}` }
17-
});
18-
return ZoomMeetingSchema.parse(response);
19-
}
21+
headers: { Authorization: `Bearer ${token}` },
22+
},
23+
);
24+
return ZoomMeetingSchema.parse(response);
25+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /