# Announcing Acorn AI

WordPress 6.9 introduced the [Abilities API](https://make.wordpress.org/ai/2025/07/17/abilities-api/) — a standardized way to define capabilities that AI agents can invoke via REST and the [WordPress MCP Adapter](https://github.com/WordPress/mcp-adapter). Around the same time, Laravel shipped [laravel/ai](https://github.com/laravel/ai), bringing first-class AI provider support to the framework.

We built `<a href="https://github.com/roots/acorn-ai">roots/acorn-ai</a>` to bring both of these together in a way that feels natural for Acorn developers.

## The problem

Registering a WordPress ability today means wiring up plain PHP callables and manually bootstrapping any dependencies they need. There's no dependency injection, no container resolution, and nothing connecting your WordPress abilities to the AI providers you're already configuring in your Laravel app.

## The solution

Acorn AI lets you define abilities as Laravel-style classes, resolved through Acorn's service container. Your abilities get full constructor injection, and `laravel/ai` is wired up automatically — so you can call OpenAI, Anthropic, Gemini, or any other supported provider from the same config you're already familiar with.

## Installation

```
$ composer require roots/acorn-ai

```

 Copy

Publish the WordPress-specific config:

```
$ wp acorn vendor:publish --provider="Roots\AcornAi\AcornAiServiceProvider" --tag=ai-wordpress-config

```

 Copy

Publish the AI provider config:

```
$ wp acorn vendor:publish --provider="Laravel\Ai\AiServiceProvider" --tag=ai-config

```

 Copy

## WordPress AI Connectors

API keys configured in your `.env` file for `laravel/ai` are automatically shared with WordPress AI provider plugins (`ai-provider-for-anthropic`, `ai-provider-for-openai`, `ai-provider-for-google`). This means:

- **No duplicate configuration** — set your API keys once in `.env` and both Laravel and WordPress use them
- **No wp-admin required** — skip the WordPress Connectors settings page entirely (coming in WordPress 7.0)
- **Keys stay out of the database** — WordPress's Connectors UI stores keys in `wp_options` as plaintext; Acorn AI bypasses that by populating the environment at runtime

If you've already added your keys to `.env`:

```
ANTHROPIC_API_KEY=sk-ant-...
OPENAI_API_KEY=sk-...
GEMINI_API_KEY=...
```

They'll be picked up automatically. Existing environment variables are never overwritten.

## Defining abilities

Generate a new ability with:

```
$ wp acorn make:ability SummarizePost

```

 Copy

This creates `app/Ai/Abilities/SummarizePostAbility.php`. Because abilities are resolved through the container, constructor injection works as expected:

```
class SummarizePostAbility extends Ability
{
    public function __construct(private PostRepository $posts) {}

    public function execute(array $input): mixed
    {
        return AnonymousAgent::make(
            instructions: 'Summarize this post in 2-3 sentences.',
            messages: [],
            tools: [],
        )->prompt($this->posts->getContent($input['post_id']))->text;
    }
}

```

Register the ability in `config/ai-wordpress.php`:

```
'abilities' => [
    \App\Ai\Abilities\SummarizePostAbility::class,
],

```

## MCP Adapter support

Abilities can be exposed as MCP tools for AI agents like Claude or Cursor by setting `mcp.public` in the `meta()` method:

```
public function meta(): array
{
    return [
        'mcp' => ['public' => true],
    ];
}

```

When the WordPress MCP Adapter plugin is active, any ability with this flag is automatically surfaced — no additional configuration needed.

## How it works

Acorn AI hooks into `wp_abilities_api_init` and iterates your configured ability classes, resolving each one through the Laravel service container before passing the callbacks to `wp_register_ability()`. This means your execute and permission callbacks have access to any service bound in the container, while WordPress core handles the REST routing, input validation, and schema enforcement.

`laravel/ai` is included as a dependency and auto-registers via Acorn's package discovery — so `make:agent`, `make:tool`, and the full provider configuration are available out of the box.

Acorn AI v0.1.0 is available now. [Check out the repository to get started](https://github.com/roots/acorn-ai).