mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
|
Some checks are pending
DevInfra / assistant_to_the_branch_manager (push) Waiting to run
This is an ergonomic wrapper around `declareWebMcpTool`, allowing a user to define multiple tools directly on an injector's providers, rather than needing to find an injection context.
Example:
```typescript
import {bootstrapApplication, provideWebMcpTools} from '@angular/core';
await bootstrapApplication(RootComp, {
providers: [
provideWebMcpTools([
{
name: 'hello',
description: 'Says hello',
inputSchema: {type: 'object', properties: {}},
execute: async () => ({content: [{type: 'text', text: 'Hello, World!'}]});
},
]),
],
});
```
The `execute` function is invoked in the injection context of the `Injector` it is provided to, meaning you can easily `inject` dependencies and invoke them.
This also works particularly well with route `providers` and `withExperimentalAutoCleanupInjectors`, registering the tools when the router is navigated to and then automatically unregistering them when navigating away. Note that `withExperimentalAutoCleanupInjectors` is required for unregistration to work.
```typescript
import {provideWebMcpTools} from '@angular/core';
import {provideRouter} from '@angular/router';
provideRouter(
[
{
path: '',
component: Home,
providers: [
provideWebMcpTools([
{
name: 'hello',
description: 'Says hello',
inputSchema: {type: 'object', properties: {}},
execute: async () => ({content: [{type: 'text', text: 'Hello, World!'}]}),
},
]),
],
},
],
withExperimentalAutoCleanupInjectors(),
);
```
|
||
|---|---|---|
| .. | ||
| acceptance | ||
| animation | ||
| animation_utils | ||
| authoring | ||
| bundling | ||
| change_detection | ||
| compiler | ||
| debug | ||
| di | ||
| dom | ||
| hydration | ||
| i18n | ||
| legacy_animation | ||
| linker | ||
| metadata | ||
| reflection | ||
| render3 | ||
| resource | ||
| sanitization | ||
| signals | ||
| strict_types | ||
| testability | ||
| util | ||
| webmcp | ||
| zone | ||
| application_config_spec.ts | ||
| application_init_spec.ts | ||
| application_module_spec.ts | ||
| application_ref_integration_spec.ts | ||
| application_ref_spec.ts | ||
| BUILD.bazel | ||
| change_detection_scheduler_spec.ts | ||
| component_fixture_spec.ts | ||
| defer_fixture_spec.ts | ||
| dev_mode_spec.ts | ||
| directive_lifecycle_integration_spec.ts | ||
| error_handler_spec.ts | ||
| event_emitter_spec.ts | ||
| fake_async_spec.ts | ||
| forward_ref_integration_spec.ts | ||
| runtime_error_spec.ts | ||
| test_bed_effect_spec.ts | ||
| test_bed_spec.ts | ||
| transfer_state_spec.ts | ||