Skip to content

Commit 04e10ec

Browse files
committed
Add API credential and allowed origin GET calls to mcp
1 parent 81d66f6 commit 04e10ec

8 files changed

Lines changed: 204 additions & 6 deletions

File tree

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,12 @@ The [Adyen Model Context Protocol (MCP) server](https://docs.adyen.com/developme
3030
- List all webhooks - GET [`/merchants/{merchantId}/webhooks`](https://docs.adyen.com/api-explorer/Management/3/get/merchants/(merchantId)/webhooks)
3131
- Get a webhook - GET [`/companies/{companyId}/webhooks/{webhookId}`](https://docs.adyen.com/api-explorer/Management/3/get/companies/(companyId)/webhooks/(webhookId))
3232
- Get a webhook - GET [`/merchants/{merchantId}/webhooks/{webhookId}`](https://docs.adyen.com/api-explorer/Management/3/get/merchants/(merchantId)/webhooks/(webhookId))
33-
33+
7. Management API - API Credentials
34+
- List all API Credentials - GET [`/companies/{companyId}/apiCredentials`](https://docs.adyen.com/api-explorer/Management/3/get/companies/(companyId)/apiCredentials)
35+
- List all API Credentials - GET [`/merchants/{merchantId}/apiCredentials`](https://docs.adyen.com/api-explorer/Management/3/get/merchants/(merchantId)/apiCredentials)
36+
8. Management API - Allowed Origins
37+
- List all allowed origins - GET [`/companies/{companyId}/apiCredentials/{apiCredentialId}/allowedOrigins`](https://docs.adyen.com/api-explorer/Management/3/get/companies/(companyId)/apiCredentials/(apiCredentialId)/allowedOrigins)
38+
- List all allowed origins - GET [`/merchants/{merchantId}/apiCredentials/{apiCredentialId}/allowedOrigins`](https://docs.adyen.com/api-explorer/Management/3/get/merchants/(merchantId)/apiCredentials/(apiCredentialId)/allowedOrigins)
3439

3540
### Usage
3641
* Run the MCP server via `npx` with the following command:
@@ -75,6 +80,7 @@ Example usage in `.vscode`:
7580
* Management API — Terminal settings read
7681
* Management API — Terminal settings read and write
7782
* Management API — Webhooks read
83+
* Management API — API credentials read
7884

7985
Adyen recommends creating a new webservice user and generating a new API key for the purpose of this application.
8086
Only use the new user’s API key for the MCP application and limit the roles to match the tools you'll be using.

typescript/README.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,15 @@ The Adyen Model Context Protocol server allows you to integrate with Adyen APIs
2828
6. Management API - Webhooks
2929
- List all webhooks
3030
- Get a webhook
31-
7. Configuration API - Account Holders
31+
7. Management API - API Credentials
32+
- Get a list of API Credentials
33+
8. Management API - Allowed Origins
34+
- Get a list of allowed origins
35+
9. Configuration API - Account Holders
3236
- Get account holder details and its capability settings.
33-
8. Legal entity management API - Legal entities and onboarding links
34-
- Get legal entity details and its KYC information.
35-
- Create an onboarding link for a legal entity.
37+
10. Legal entity management API - Legal entities and onboarding links
38+
- Get legal entity details and its KYC information.
39+
- Create an onboarding link for a legal entity.
3640

3741
### Usage
3842
To run to the MCP server via `npx` you can execute:
@@ -60,6 +64,7 @@ npx -y @adyen/mcp --adyenApiKey=YOUR_ADYEN_API_KEY --env=LIVE --livePrefix=YOUR_
6064
* Management API — Terminal settings read
6165
* Management API — Terminal settings read and write
6266
* Management API — Webhooks read
67+
* Management API — API credentials read
6368

6469
Adyen recommends creating a new webservice user and generating a new API key for the purpose of this application.
6570
Only use the new user’s API key for the MCP application and limit the roles to match the tools you'll be using.

typescript/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
"engines": {
66
"node": ">=18"
77
},
8-
"type": "module",
98
"author": "Adyen",
109
"bin": {
1110
"mcp": "./dist/index.js"
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
import { z } from 'zod';
2+
import { Client, ManagementAPI } from '@adyen/api-library';
3+
import { Tool } from '../../types.js';
4+
5+
const listAllMerchantAllowedOriginsRequestObject = z.object({
6+
merchantId: z
7+
.string()
8+
.describe('The unique identifier of the merchant account.'),
9+
apiCredentialId: z
10+
.string()
11+
.describe('Unique identifier of the API credential.'),
12+
});
13+
14+
const listAllMerchantAllowedOrigins = async (
15+
client: Client,
16+
{
17+
merchantId,
18+
apiCredentialId,
19+
}: z.infer<typeof listAllMerchantAllowedOriginsRequestObject>,
20+
) => {
21+
const managementAPI = new ManagementAPI(client);
22+
try {
23+
return await managementAPI.AllowedOriginsMerchantLevelApi.listAllowedOrigins(
24+
merchantId,
25+
apiCredentialId,
26+
);
27+
} catch (e) {
28+
return (
29+
'Failed to list all api credential configurations on merchant account. Error: ' +
30+
JSON.stringify(e)
31+
);
32+
}
33+
};
34+
35+
export const listAllMerchantAllowedOriginsTool: Tool = {
36+
name: 'list_all_merchant_allowed_origins',
37+
description:
38+
'Returns the list of allowed origins for the API credential identified in the path.',
39+
arguments: listAllMerchantAllowedOriginsRequestObject,
40+
invoke: listAllMerchantAllowedOrigins,
41+
};
42+
43+
const listAllCompanyAllowedOriginsRequestObject = z.object({
44+
companyId: z
45+
.string()
46+
.describe('The unique identifier of the company account.'),
47+
apiCredentialId: z
48+
.string()
49+
.describe('Unique identifier of the API credential.'),
50+
});
51+
52+
const listAllCompanyAllowedOrigins = async (
53+
client: Client,
54+
{
55+
companyId,
56+
apiCredentialId,
57+
}: z.infer<typeof listAllCompanyAllowedOriginsRequestObject>,
58+
) => {
59+
const managementAPI = new ManagementAPI(client);
60+
try {
61+
return await managementAPI.AllowedOriginsCompanyLevelApi.listAllowedOrigins(
62+
companyId,
63+
apiCredentialId,
64+
);
65+
} catch (e) {
66+
return (
67+
'Failed to list all api credential configurations on company account. Error: ' +
68+
JSON.stringify(e)
69+
);
70+
}
71+
};
72+
73+
export const listAllCompanyAllowedOriginsTool: Tool = {
74+
name: 'list_all_company_allowed_origins',
75+
description:
76+
'Returns the list of allowed origins for the API credential identified in the path.',
77+
arguments: listAllCompanyAllowedOriginsRequestObject,
78+
invoke: listAllCompanyAllowedOrigins,
79+
};
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
import { z } from 'zod';
2+
import { Client, ManagementAPI } from '@adyen/api-library';
3+
import { Tool } from '../../types.js';
4+
5+
const listAllMerchantApiCredentialsRequestObject = z.object({
6+
merchantId: z
7+
.string()
8+
.describe('The unique identifier of the merchant account.'),
9+
pageSize: z
10+
.number()
11+
.optional()
12+
.describe(
13+
'The number of items to have on a page, maximum 100. The default is 10 items on a page.',
14+
),
15+
pageNumber: z
16+
.number()
17+
.optional()
18+
.describe('The number of the page to fetch.'),
19+
});
20+
21+
const listAllMerchantApiCredentials = async (
22+
client: Client,
23+
{
24+
merchantId,
25+
pageSize,
26+
pageNumber,
27+
}: z.infer<typeof listAllMerchantApiCredentialsRequestObject>,
28+
) => {
29+
const managementAPI = new ManagementAPI(client);
30+
try {
31+
return await managementAPI.APICredentialsMerchantLevelApi.listApiCredentials(
32+
merchantId,
33+
pageNumber,
34+
pageSize,
35+
);
36+
} catch (e) {
37+
return (
38+
'Failed to list all api credential configurations on merchant account. Error: ' +
39+
JSON.stringify(e)
40+
);
41+
}
42+
};
43+
44+
export const listAllMerchantApiCredentialsTool: Tool = {
45+
name: 'list_all_merchant_api_credentials',
46+
description:
47+
'Returns the list of API credentials for the merchant account. The list is grouped into pages as defined by the query parameters.',
48+
arguments: listAllMerchantApiCredentialsRequestObject,
49+
invoke: listAllMerchantApiCredentials,
50+
};
51+
52+
const listAllCompanyApiCredentialsRequestObject = z.object({
53+
companyId: z
54+
.string()
55+
.describe('The unique identifier of the company account.'),
56+
pageSize: z
57+
.number()
58+
.optional()
59+
.describe(
60+
'The number of items to have on a page, maximum 100. The default is 10 items on a page.',
61+
),
62+
pageNumber: z
63+
.number()
64+
.optional()
65+
.describe('The number of the page to fetch.'),
66+
});
67+
68+
const listAllCompanyApiCredentials = async (
69+
client: Client,
70+
{
71+
companyId,
72+
pageNumber,
73+
pageSize,
74+
}: z.infer<typeof listAllCompanyApiCredentialsRequestObject>,
75+
) => {
76+
const managementAPI = new ManagementAPI(client);
77+
try {
78+
return await managementAPI.APICredentialsCompanyLevelApi.listApiCredentials(
79+
companyId,
80+
pageNumber,
81+
pageSize,
82+
);
83+
} catch (e) {
84+
return (
85+
'Failed to list all api credential configurations on company account. Error: ' +
86+
JSON.stringify(e)
87+
);
88+
}
89+
};
90+
91+
export const listAllCompanyApiCredentialsTool: Tool = {
92+
name: 'list_all_company_api_credentials',
93+
description:
94+
'Returns the list of API credentials for the company account. The list is grouped into pages as defined by the query parameters.',
95+
arguments: listAllCompanyApiCredentialsRequestObject,
96+
invoke: listAllCompanyApiCredentials,
97+
};

typescript/src/tools/tools.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,14 @@ import {
2727
listAllCompanyWebhooksTool,
2828
listAllMerchantWebhooksTool,
2929
} from './management/webhooks/index.js';
30+
import {
31+
listAllCompanyApiCredentialsTool,
32+
listAllMerchantApiCredentialsTool,
33+
} from './management/apiCredentials/index.js';
34+
import {
35+
listAllCompanyAllowedOriginsTool,
36+
listAllMerchantAllowedOriginsTool,
37+
} from './management/allowedOrigins/index.js';
3038

3139
export const tools: Tool[] = [
3240
createPaymentLinkTool,
@@ -47,4 +55,8 @@ export const tools: Tool[] = [
4755
getCompanyWebhookTool,
4856
listAllMerchantWebhooksTool,
4957
getMerchantWebhookTool,
58+
listAllCompanyApiCredentialsTool,
59+
listAllMerchantApiCredentialsTool,
60+
listAllCompanyAllowedOriginsTool,
61+
listAllMerchantAllowedOriginsTool,
5062
];

0 commit comments

Comments
 (0)