tommitt commited on
Commit
b9a48fb
·
unverified ·
1 Parent(s): 3959209

Eunomia authorization server can run embedded within the MCP server (#1317)

Browse files
docs/integrations/eunomia-authorization.mdx CHANGED
@@ -1,7 +1,7 @@
1
  ---
2
  title: Eunomia Authorization 🤝 FastMCP
3
  sidebarTitle: Eunomia Auth
4
- description: Add policy-based authorization to your FastMCP servers
5
  icon: shield-check
6
  tag: NEW
7
  ---
@@ -12,7 +12,7 @@ Control which tools, resources and prompts MCP clients can view and execute on y
12
 
13
  ## How it Works
14
 
15
- Exploiting FastMCP's [Middleware][fastmcp-middleare], the Eunomia middleware intercepts all MCP requests to your server and, then, automatically maps MCP methods to authorization checks.
16
 
17
  ### Listing Operations
18
 
@@ -56,13 +56,7 @@ sequenceDiagram
56
  ## Add Authorization to Your Server
57
 
58
  <Note>
59
- Eunomia is an AI-specific standalone authorization server that handles policy decisions. You must have an Eunomia server running alongside your FastMCP server for the middleware to function.
60
-
61
- Run it in the background with Docker:
62
-
63
- ```bash
64
- docker run -d -p 8000:8000 ttommitt/eunomia-server:latest
65
- ```
66
 
67
  </Note>
68
 
@@ -78,17 +72,19 @@ Then create a FastMCP server and add the Eunomia middleware in one line:
78
 
79
  ```python server.py
80
  from fastmcp import FastMCP
81
- from eunomia_mcp import EunomiaMcpMiddleware
82
 
83
- mcp = FastMCP("Secure FastMCP Server 🔒")
 
84
 
85
  @mcp.tool()
86
  def add(a: int, b: int) -> int:
87
  """Add two numbers"""
88
  return a + b
89
 
90
- middleware = EunomiaMcpMiddleware()
91
- app = mcp.add_middleware(middleware)
 
92
 
93
  if __name__ == "__main__":
94
  mcp.run()
@@ -99,18 +95,18 @@ if __name__ == "__main__":
99
  Use the `eunomia-mcp` CLI in your terminal to manage your authorization policies:
100
 
101
  ```bash
102
- # Create a default policy configuration file
103
  eunomia-mcp init
 
 
 
104
  ```
105
 
106
- This creates a policy file you can customize to control access to your MCP tools and resources.
107
 
108
  ```bash
109
- # Once ready, validate your policy
110
  eunomia-mcp validate mcp_policies.json
111
-
112
- # And push it to the Eunomia server
113
- eunomia-mcp push mcp_policies.json
114
  ```
115
 
116
  ### Run the Server
@@ -124,8 +120,8 @@ python server.py
124
  The middleware will now intercept all MCP requests and check them against your policies. Requests include agent identification through headers like `X-Agent-ID`, `X-User-ID`, `User-Agent`, or `Authorization` and an automatic mapping of MCP methods to authorization resources and actions.
125
 
126
  <Tip>
127
- For detailed policy configuration, custom authentication, and advanced
128
- deployment patterns, visit the [Eunomia MCP Middleware
129
  repository][eunomia-mcp-github].
130
  </Tip>
131
 
 
1
  ---
2
  title: Eunomia Authorization 🤝 FastMCP
3
  sidebarTitle: Eunomia Auth
4
+ description: Add policy-based authorization to your FastMCP servers with Eunomia
5
  icon: shield-check
6
  tag: NEW
7
  ---
 
12
 
13
  ## How it Works
14
 
15
+ Exploiting FastMCP's [Middleware][fastmcp-middleare], the Eunomia middleware intercepts all MCP requests to your server and automatically maps MCP methods to authorization checks.
16
 
17
  ### Listing Operations
18
 
 
56
  ## Add Authorization to Your Server
57
 
58
  <Note>
59
+ Eunomia is an AI-specific authorization server that handles policy decisions. The server runs embedded within your MCP server by default for a zero-effort configuration, but can alternatively be run remotely for centralized policy decisions.
 
 
 
 
 
 
60
 
61
  </Note>
62
 
 
72
 
73
  ```python server.py
74
  from fastmcp import FastMCP
75
+ from eunomia_mcp import create_eunomia_middleware
76
 
77
+ # Create your FastMCP server
78
+ mcp = FastMCP("Secure MCP Server 🔒")
79
 
80
  @mcp.tool()
81
  def add(a: int, b: int) -> int:
82
  """Add two numbers"""
83
  return a + b
84
 
85
+ # Add middleware to your server
86
+ middleware = create_eunomia_middleware(policy_file="mcp_policies.json")
87
+ mcp.add_middleware(middleware)
88
 
89
  if __name__ == "__main__":
90
  mcp.run()
 
95
  Use the `eunomia-mcp` CLI in your terminal to manage your authorization policies:
96
 
97
  ```bash
98
+ # Create a default policy file
99
  eunomia-mcp init
100
+
101
+ # Or create a policy file customized for your FastMCP server
102
+ eunomia-mcp init --custom-mcp "app.server:mcp"
103
  ```
104
 
105
+ This creates `mcp_policies.json` file that you can further edit to your access control needs.
106
 
107
  ```bash
108
+ # Once edited, validate your policy file
109
  eunomia-mcp validate mcp_policies.json
 
 
 
110
  ```
111
 
112
  ### Run the Server
 
120
  The middleware will now intercept all MCP requests and check them against your policies. Requests include agent identification through headers like `X-Agent-ID`, `X-User-ID`, `User-Agent`, or `Authorization` and an automatic mapping of MCP methods to authorization resources and actions.
121
 
122
  <Tip>
123
+ For detailed policy configuration, custom authentication, and remote
124
+ deployments, visit the [Eunomia MCP Middleware
125
  repository][eunomia-mcp-github].
126
  </Tip>
127