@ory/mcp-server 0.1.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.
@@ -0,0 +1,181 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.registerRelationshipTools = registerRelationshipTools;
4
+ const zod_1 = require("zod");
5
+ const executor_js_1 = require("../executor.js");
6
+ const projectParam = zod_1.z.string().optional().describe("Ory project ID or slug");
7
+ const workspaceParam = zod_1.z.string().optional().describe("Ory workspace ID or name");
8
+ function registerRelationshipTools(server) {
9
+ server.registerTool("ory_list_relationships", {
10
+ title: "List Relationships",
11
+ description: "List relationship tuples matching the given filter criteria. All filter parameters are optional.",
12
+ inputSchema: {
13
+ namespace: zod_1.z.string().optional().describe("Filter by namespace"),
14
+ object: zod_1.z.string().optional().describe("Filter by object"),
15
+ relation: zod_1.z.string().optional().describe("Filter by relation"),
16
+ subject_id: zod_1.z.string().optional().describe("Filter by subject ID"),
17
+ subject_set: zod_1.z
18
+ .string()
19
+ .optional()
20
+ .describe('Filter by subject set (format: "namespace:object#relation")'),
21
+ page_size: zod_1.z
22
+ .number()
23
+ .int()
24
+ .positive()
25
+ .optional()
26
+ .describe("Maximum items per page (default 100)"),
27
+ page_token: zod_1.z
28
+ .string()
29
+ .optional()
30
+ .describe("Pagination token from previous response"),
31
+ project: projectParam,
32
+ workspace: workspaceParam,
33
+ },
34
+ }, async (params) => {
35
+ const args = ["list", "relationships", ...(0, executor_js_1.buildCommonArgs)(params)];
36
+ if (params.namespace)
37
+ args.push("--namespace", params.namespace);
38
+ if (params.object)
39
+ args.push("--object", params.object);
40
+ if (params.relation)
41
+ args.push("--relation", params.relation);
42
+ if (params.subject_id)
43
+ args.push("--subject-id", params.subject_id);
44
+ if (params.subject_set)
45
+ args.push("--subject-set", params.subject_set);
46
+ if (params.page_size)
47
+ args.push("--page-size", String(params.page_size));
48
+ if (params.page_token)
49
+ args.push("--page-token", params.page_token);
50
+ return (0, executor_js_1.execOryTool)(args);
51
+ });
52
+ server.registerTool("ory_create_relationship", {
53
+ title: "Create Relationship",
54
+ description: "Create a relationship tuple. Example: User:alice can view Doc:readme.",
55
+ inputSchema: {
56
+ namespace: zod_1.z.string().describe("Namespace (e.g. Doc)"),
57
+ object: zod_1.z.string().describe("Object within the namespace (e.g. readme)"),
58
+ relation: zod_1.z.string().describe("Relation (e.g. view, owner, editor)"),
59
+ subject_id: zod_1.z
60
+ .string()
61
+ .describe("Subject identifier (e.g. User:alice)"),
62
+ project: projectParam,
63
+ workspace: workspaceParam,
64
+ },
65
+ }, async (params) => {
66
+ const args = [
67
+ "create",
68
+ "relationships",
69
+ params.subject_id,
70
+ params.relation,
71
+ params.namespace,
72
+ params.object,
73
+ ...(0, executor_js_1.buildCommonArgs)(params),
74
+ ];
75
+ return (0, executor_js_1.execOryTool)(args);
76
+ });
77
+ server.registerTool("ory_delete_relationships", {
78
+ title: "Delete Relationships",
79
+ description: "Delete ALL relationships matching the given filter. At least one filter parameter should be provided.",
80
+ inputSchema: {
81
+ namespace: zod_1.z.string().optional().describe("Filter by namespace"),
82
+ object: zod_1.z.string().optional().describe("Filter by object"),
83
+ relation: zod_1.z.string().optional().describe("Filter by relation"),
84
+ subject_id: zod_1.z.string().optional().describe("Filter by subject ID"),
85
+ project: projectParam,
86
+ workspace: workspaceParam,
87
+ },
88
+ }, async (params) => {
89
+ const args = ["delete", "relationships", ...(0, executor_js_1.buildCommonArgs)(params)];
90
+ if (params.namespace)
91
+ args.push("--namespace", params.namespace);
92
+ if (params.object)
93
+ args.push("--object", params.object);
94
+ if (params.relation)
95
+ args.push("--relation", params.relation);
96
+ if (params.subject_id)
97
+ args.push("--subject-id", params.subject_id);
98
+ return (0, executor_js_1.execOryTool)(args);
99
+ });
100
+ server.registerTool("ory_create_relationships_from_file", {
101
+ title: "Create Relationships from File",
102
+ description: "Create one or more relationship tuples from a JSON file or inline JSON content.",
103
+ inputSchema: {
104
+ content: zod_1.z
105
+ .string()
106
+ .optional()
107
+ .describe("Relationship JSON (single tuple or array of tuples). Used if 'file' is not provided."),
108
+ file: zod_1.z
109
+ .string()
110
+ .optional()
111
+ .describe("Path to a JSON file or directory (takes precedence over content)."),
112
+ project: projectParam,
113
+ workspace: workspaceParam,
114
+ },
115
+ }, async (params) => (0, executor_js_1.withFileOrContent)(params, ".json", (filePath) => {
116
+ const args = [
117
+ "create",
118
+ "relationships",
119
+ "--file",
120
+ filePath,
121
+ ...(0, executor_js_1.buildCommonArgs)(params),
122
+ ];
123
+ return (0, executor_js_1.execOryTool)(args);
124
+ }));
125
+ server.registerTool("ory_parse_relationships", {
126
+ title: "Parse Relationships",
127
+ description: "Parse human-readable relationship tuples (Keto syntax) into the JSON format used by the Ory APIs.",
128
+ inputSchema: {
129
+ content: zod_1.z
130
+ .string()
131
+ .optional()
132
+ .describe("Tuple definitions in human-readable form. Used if 'file' is not provided."),
133
+ file: zod_1.z
134
+ .string()
135
+ .optional()
136
+ .describe("Path to a tuple file or directory (takes precedence over content)."),
137
+ project: projectParam,
138
+ workspace: workspaceParam,
139
+ },
140
+ }, async (params) => (0, executor_js_1.withFileOrContent)(params, ".txt", (filePath) => {
141
+ const args = [
142
+ "parse",
143
+ "relationships",
144
+ "--file",
145
+ filePath,
146
+ ...(0, executor_js_1.buildCommonArgs)(params),
147
+ ];
148
+ return (0, executor_js_1.execOryTool)(args);
149
+ }));
150
+ server.registerTool("ory_check_permission", {
151
+ title: "Check Permission",
152
+ description: 'Check whether a subject has a relation on an object (e.g. "Is User:alice allowed to view Doc:readme?").',
153
+ inputSchema: {
154
+ subject: zod_1.z.string().describe("Subject (e.g. User:alice)"),
155
+ relation: zod_1.z.string().describe("Relation to check (e.g. view)"),
156
+ namespace: zod_1.z.string().describe("Namespace (e.g. Doc)"),
157
+ object: zod_1.z.string().describe("Object (e.g. readme)"),
158
+ max_depth: zod_1.z
159
+ .number()
160
+ .int()
161
+ .positive()
162
+ .optional()
163
+ .describe("Maximum search tree depth"),
164
+ project: projectParam,
165
+ workspace: workspaceParam,
166
+ },
167
+ }, async (params) => {
168
+ const args = [
169
+ "is",
170
+ "allowed",
171
+ params.subject,
172
+ params.relation,
173
+ params.namespace,
174
+ params.object,
175
+ ...(0, executor_js_1.buildCommonArgs)(params),
176
+ ];
177
+ if (params.max_depth)
178
+ args.push("--max-depth", String(params.max_depth));
179
+ return (0, executor_js_1.execOryTool)(args);
180
+ });
181
+ }
@@ -0,0 +1,2 @@
1
+ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ export declare function registerWorkspaceTools(server: McpServer): void;
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.registerWorkspaceTools = registerWorkspaceTools;
4
+ const zod_1 = require("zod");
5
+ const executor_js_1 = require("../executor.js");
6
+ function registerWorkspaceTools(server) {
7
+ server.registerTool("ory_list_workspaces", {
8
+ title: "List Workspaces",
9
+ description: "List Ory Network workspaces accessible to the current account.",
10
+ inputSchema: {},
11
+ }, async () => {
12
+ const args = ["list", "workspaces", ...(0, executor_js_1.buildCommonArgs)({})];
13
+ return (0, executor_js_1.execOryTool)(args);
14
+ });
15
+ server.registerTool("ory_get_workspace", {
16
+ title: "Get Workspace",
17
+ description: "Get details about an Ory Network workspace by ID.",
18
+ inputSchema: {
19
+ id: zod_1.z.string().describe("Workspace ID"),
20
+ },
21
+ }, async (params) => {
22
+ const args = ["get", "workspace", params.id, ...(0, executor_js_1.buildCommonArgs)({})];
23
+ return (0, executor_js_1.execOryTool)(args);
24
+ });
25
+ server.registerTool("ory_create_workspace", {
26
+ title: "Create Workspace",
27
+ description: "Create a new Ory Network workspace.",
28
+ inputSchema: {
29
+ name: zod_1.z.string().describe("Workspace name"),
30
+ },
31
+ }, async (params) => {
32
+ const args = [
33
+ "create",
34
+ "workspace",
35
+ "--name",
36
+ params.name,
37
+ ...(0, executor_js_1.buildCommonArgs)({}),
38
+ ];
39
+ return (0, executor_js_1.execOryTool)(args);
40
+ });
41
+ }
package/package.json ADDED
@@ -0,0 +1,70 @@
1
+ {
2
+ "name": "@ory/mcp-server",
3
+ "version": "0.1.0",
4
+ "description": "MCP server exposing the Ory CLI and Ory Network REST API as tools for AI agents to manage identities, OAuth2 clients, permissions, projects, and configuration",
5
+ "license": "Apache-2.0",
6
+ "homepage": "https://ory.com",
7
+ "keywords": [
8
+ "ory",
9
+ "mcp",
10
+ "mcp-server",
11
+ "model-context-protocol",
12
+ "cli",
13
+ "identity",
14
+ "identity-management",
15
+ "iam",
16
+ "authentication",
17
+ "authorization",
18
+ "access-control",
19
+ "permissions",
20
+ "rbac",
21
+ "zanzibar",
22
+ "oauth",
23
+ "oauth2",
24
+ "openid-connect",
25
+ "oidc",
26
+ "session",
27
+ "sso",
28
+ "agent",
29
+ "ai-agent",
30
+ "agent-security",
31
+ "guardrails",
32
+ "llm",
33
+ "kratos",
34
+ "keto",
35
+ "hydra"
36
+ ],
37
+ "publishConfig": {
38
+ "access": "public"
39
+ },
40
+ "main": "dist/index.js",
41
+ "types": "dist/index.d.ts",
42
+ "exports": {
43
+ ".": {
44
+ "types": "./dist/index.d.ts",
45
+ "default": "./dist/index.js"
46
+ }
47
+ },
48
+ "bin": {
49
+ "ory-mcp-server": "dist/index.js"
50
+ },
51
+ "files": [
52
+ "dist",
53
+ "!dist/**/*.tsbuildinfo"
54
+ ],
55
+ "dependencies": {
56
+ "@modelcontextprotocol/sdk": "^1.29.0",
57
+ "zod": "^4.4.3"
58
+ },
59
+ "engines": {
60
+ "node": ">=24"
61
+ },
62
+ "scripts": {
63
+ "build": "tsc",
64
+ "clean": "rm -rf dist *.tsbuildinfo",
65
+ "pretest": "pnpm run build",
66
+ "test": "vitest run",
67
+ "test:watch": "vitest",
68
+ "typecheck": "tsc --noEmit"
69
+ }
70
+ }