micro--go-micro
a0ad9ee566
* docs: add AI provider integration guide and Supported AI Providers section Add a step-by-step guide for AI infrastructure companies to implement ai.Model and contribute a provider to go-micro. Covers the full lifecycle: skeleton, tool call handling, tests, registration, and PR checklist. Add a "Supported AI Providers" section to the project README that lists current providers (Anthropic, OpenAI) in a table and links to the integration guide with a call-to-action for new providers and sponsors. Streamline the "Adding a New Provider" section in ai/README.md to point to the new guide instead of duplicating a full code listing. * fix: remove nonexistent Discord link from README * fix(website): set content container width to 800px on desktop Move the 800px max-width from .markdown-body up to .content so the entire content pane (not just the inner body) is sized correctly. The container now fills up to 800px beside the sidebar. * feat(ai): wire Atlas Cloud into server and auto-detection Import atlascloud provider in the micro server so it is available when running micro run / micro server. Add atlascloud to AutoDetectProvider so --ai_base_url with an atlascloud domain selects the right provider automatically. * feat(ai): add Google Gemini provider Add ai/gemini implementing ai.Model for Google's Gemini API. Uses the native generateContent endpoint with system_instruction, contents/parts, and functionDeclarations — not an OpenAI shim. Default model gemini-2.5-flash, auth via x-goog-api-key header. Wire into micro server imports and AutoDetectProvider (matches googleapis.com and google in base URL). Update README.md and ai/README.md with provider listing. * feat(ai): add Groq, Mistral, and Together AI providers Add three new OpenAI-compatible providers: - ai/groq: ultra-fast inference, default model llama-3.3-70b-versatile - ai/mistral: Mistral AI, default model mistral-large-latest - ai/together: Together AI, default model Llama-3.3-70B-Instruct-Turbo All three are wired into the micro server imports and AutoDetectProvider. README and ai/README updated with the full provider table. * feat(ai): add ai/tools helper and 'micro chat' interactive agent Extract the registry-discovery + RPC-execution loop from the web agent playground into a reusable ai/tools package: - tools.New(reg) creates a Set bound to a registry - Set.Discover() walks the registry and returns []ai.Tool with LLM-safe (underscored) names, remembering the mapping back to the original dotted form - Set.Handler(client) returns an ai.ToolHandler that resolves the safe name and issues the RPC Add cmd/micro/chat — an interactive 'micro chat' REPL that uses ai/tools to let users talk to their services through any registered AI provider. Supports --prompt for single-shot use, auto-detects the provider from --base_url, and falls back to the provider's conventional env var (ANTHROPIC_API_KEY, etc). Update README with the new command and the programmatic example. * feat(examples): add gRPC interop example Add examples/grpc-interop showing that any standard gRPC client can call a go-micro service — no go-micro SDK required on the client side. Includes: - proto/greeter.proto with generated Go, gRPC, and micro stubs - server/ using go-micro gRPC transport - client/ using stock google.golang.org/grpc (no go-micro imports) - README with Python example and explanation of how routing works Addresses the confusion from issue #2818 where users didn't know that go-micro gRPC services are callable by any gRPC client. * fix: strip /api prefix from MCP routes Change /api/mcp/tools and /api/mcp/call to /mcp/tools and /mcp/call. MCP is a first-class feature, not a sub-path of the API proxy. Update server routes, playground template, scopes template, run.go output, README, CLI README, and all docs. --------- Co-authored-by: Claude <noreply@anthropic.com>
88 行
4.2 KiB
HTML
88 行
4.2 KiB
HTML
{{define "content"}}
|
|
<h2 class="text-2xl font-bold mb-4">Scopes</h2>
|
|
<p style="color:#666; margin-bottom:1.5em;">
|
|
Set which scopes are required to call each endpoint. Tokens must carry a matching scope.
|
|
Endpoints with no scopes are open to any authenticated token.
|
|
</p>
|
|
|
|
{{if .Success}}
|
|
<div style="background:#e6ffe6; border:1px solid #5a5; padding:0.8em 1.2em; border-radius:6px; margin-bottom:1.5em; color:#050;">
|
|
✓ Scopes updated successfully.
|
|
</div>
|
|
{{end}}
|
|
|
|
<table style="margin-bottom:2em;">
|
|
<thead>
|
|
<tr><th>Service</th><th>Endpoint</th><th>Required Scopes</th><th></th></tr>
|
|
</thead>
|
|
<tbody>
|
|
{{range .Endpoints}}
|
|
<tr>
|
|
<td>{{.Service}}</td>
|
|
<td><code>{{.Endpoint}}</code></td>
|
|
<td>
|
|
{{if .Scopes}}
|
|
{{range .Scopes}}<code>{{.}}</code> {{end}}
|
|
{{else}}
|
|
<span style="color:#999;">none</span>
|
|
{{end}}
|
|
</td>
|
|
<td>
|
|
<form method="POST" action="/auth/scopes" style="display:inline; padding:0; border:0; box-shadow:none; background:none;">
|
|
<input type="hidden" name="endpoint" value="{{.Name}}">
|
|
<input name="scopes" value="{{.ScopesStr}}" placeholder="scope names" style="width:180px; margin-right:0.5em;">
|
|
<button type="submit">Save</button>
|
|
</form>
|
|
</td>
|
|
</tr>
|
|
{{end}}
|
|
{{if not .Endpoints}}
|
|
<tr>
|
|
<td colspan="4" style="color:#888; text-align:center; padding:2em;">No services discovered. Start some services and they will appear here.</td>
|
|
</tr>
|
|
{{end}}
|
|
</tbody>
|
|
</table>
|
|
|
|
<h3 style="margin-bottom:1em;">Bulk Set</h3>
|
|
<p style="color:#666; margin-bottom:1em;">Apply scopes to all endpoints matching a pattern. Use <code>*</code> as a suffix wildcard. Leave scopes empty to clear.</p>
|
|
<form method="POST" action="/auth/scopes/bulk" style="margin-bottom:2em;">
|
|
<input name="pattern" placeholder="Pattern (e.g. greeter.*)" required style="margin-right:0.5em; width:220px;">
|
|
<input name="scopes" placeholder="Scopes (comma separated)" style="margin-right:0.5em; width:220px;">
|
|
<button type="submit">Apply</button>
|
|
</form>
|
|
|
|
<h3 style="margin-bottom:1em;">Examples</h3>
|
|
<div style="background:#f9f9f9; border:1px solid #eee; padding:1.2em 1.5em; border-radius:6px; font-size:0.97em; line-height:1.6;">
|
|
|
|
<p style="margin-top:0;">Scopes are strings that you define. A call is allowed when at least one of the token's scopes matches one of the endpoint's required scopes.</p>
|
|
|
|
<h4 style="margin-top:1em; margin-bottom:0.5em;">Restrict a whole service</h4>
|
|
<p>Use Bulk Set with pattern <code>greeter.*</code> and scope <code>greeter</code>.<br>
|
|
Then create a <a href="/auth/tokens">token</a> with scope <code>greeter</code> — it can call any endpoint on that service.</p>
|
|
|
|
<h4 style="margin-top:1em; margin-bottom:0.5em;">Restrict a specific endpoint</h4>
|
|
<p>Set scope <code>billing</code> on <code>payments.Payments.Charge</code> using the table above.<br>
|
|
Only tokens with the <code>billing</code> scope can call that endpoint. Other payment endpoints remain unaffected.</p>
|
|
|
|
<h4 style="margin-top:1em; margin-bottom:0.5em;">Role-based access</h4>
|
|
<p>Set scope <code>admin</code> on sensitive endpoints (e.g. <code>users.Users.Delete</code>).<br>
|
|
Create tokens with <code>admin</code> scope for operators and <code>user</code> scope for regular access.<br>
|
|
An endpoint can require multiple scopes — the token only needs to match <b>one</b> of them.</p>
|
|
|
|
<h4 style="margin-top:1em; margin-bottom:0.5em;">Full access</h4>
|
|
<p>The default <code>admin</code> user has scope <code>*</code> which bypasses all checks.<br>
|
|
Create a token with <code>*</code> scope for services that need unrestricted access.</p>
|
|
|
|
<h4 style="margin-top:1em; margin-bottom:0.5em;">Where scopes are checked</h4>
|
|
<table style="font-size:0.95em; margin:0.5em 0;">
|
|
<thead><tr><th>Access method</th><th>How auth works</th></tr></thead>
|
|
<tbody>
|
|
<tr><td>API (<code>/api/service/endpoint</code>)</td><td><code>Authorization: Bearer <token></code> header</td></tr>
|
|
<tr><td>MCP tools (<code>/mcp/call</code>)</td><td><code>Authorization: Bearer <token></code> header</td></tr>
|
|
<tr><td>Agent playground</td><td>Uses your logged-in session and its scopes</td></tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
{{end}}
|