Perch is a developer-friendly CLI tool for scaffolding MCP HexLayer Architecture projects using clean structure and modular design.
Project description
Perch - MCP HexLayer Scaffolding CLI
Perch is a developer-friendly command-line tool for scaffolding and managing MCP HexLayer Architecture server projects.
It helps you build modular, maintainable MCP servers using clean structure and naming conventions based on primarily on CGUDL (Create, Get, Update, Delete, List), but you can use ACTION type naming conventions.
Features
- Scaffold full MCP HexLayer projects
- Add integrations, tools, services, and schemas
- Works with uv
- Built with Typer
Installation
To install Perch, use pip:
pip install perch-py
For more details, visit the Perch-Py PyPI page.
Usage
Perch provides commands to initialize new projects, create new projects in separate directories, and add various components (integrations, tools, services, schemas) to an existing project.
Initialize Project in Current Directory (perch init)
Initializes a Perch project in the current working directory.
perch init
With an optional integration:
perch init --integration github
To initialize a project where the -mcp-server suffix is not enforced on the project name:
perch init --normal # Note: Not Recommended
Create New Project (perch create)
Creates a new Perch project in a new directory. By default, if no --normal flag is used, the project name for an MCP server will be strictly suffixed with -mcp-server (e.g., my-server becomes my-server-mcp-server).
perch create my-mcp-server
With an optional integration:
perch create my-mcp-server --integration github
To create a project where the -mcp-server suffix is not enforced on the project name:
perch create my-normal-project --normal # Note: Not Recommended
After Project Initialization/Creation
After perch init or perch create, navigate into your project directory and activate the virtual environment:
cd my-mcp-server # or my-normal-project
uv venv activate
python main.py
Add Commands (perch add)
The perch add command is used to add various components to an existing Perch project.
Add Integration (perch add integration)
Adds a new integration by creating its directory structure and a client.py file.
perch add integration github
Creates:
integrations/github/
interfaces/tools/github/
interfaces/resources/github/
schemas/github/
services/github/
integrations/github/client.py
And the content of integrations/github/client.py:
# integrations/github/client.py
class GithubClient:
def __init__(self):
pass
def connect(self):
# Implement connection logic here
print(f"Connecting to {self.__class__.__name__}...")
pass
Add Tool (perch add tool)
Adds a new tool file for a given integration and entity.
perch add tool github user
Creates:
# interfaces/tools/github/user.py
from core.data.tool import ToolResponse
from pydantic import Field
from schemas.github.user import UserInputSchema, UserResponseSchema
from services.github.user import create_user
def create_user_tool(
sample1: str = Field(..., description="The sample1 of the user."),
sample2: str = Field(..., description="The sample2 of the user.")
) -> ToolResponse:
"""
Creates a new user with the provided sample1 and sample2.
"""
user = create_user(UserInputSchema.model_validate({"sample1": sample1, "sample2": sample2}))
if not user:
return ToolResponse(status="error", message="User creation failed.")
return ToolResponse(
status="success",
message="User created successfully",
data=UserResponseSchema.model_validate(user)
)
Add Service (perch add service)
Adds a new service file for a given integration and entity.
perch add service github user
Creates:
# services/github/user.py
from schemas.github.user import UserInputSchema, UserResponseSchema
import uuid
import datetime
def create_user(input_data: UserInputSchema) -> UserResponseSchema:
# Example Process
item = {
"sample1": input_data.sample1,
"sample2": input_data.sample2,
}
return UserResponseSchema(**item)
Add Schema (perch add schema)
Adds a new schema file for a given integration and entity.
perch add schema github user
Creates:
# schemas/github/user.py
from pydantic import BaseModel
from typing import Optional
class UserInputSchema(BaseModel):
sample1: str
sample2: str
class UserResponseSchema(BaseModel):
sample1: str
sample2: str
# Add other fields as necessary, e.g., id, created_at
Add All Layers (perch add all)
Adds tool, service, and schema files for a given integration and entity in one go.
perch add all github user
Creates:
# interfaces/tools/github/user.py
# services/github/user.py
# schemas/github/user.py
Constraints and Flags
Perch commands often support flags to modify their behavior.
--integration(-i): Used to specify an initial integration when creating or initializing a project.--normal(-n): This flag allows you to create a standard Python project instead of an MCP server project. When used, Perch will scaffold a basic Python project structure without the MCP-specific server components. For projects created with--normal, the-mcp-serversuffix is not enforced on the project name, allowing for more flexible naming for non-MCP projects.
- Naming Convention for MCP Server Projects: By default, when creating an MCP server project (i.e., without the
--normalflag), Perch strictly enforces that the project directory name ends with-mcp-server. For example, if you runperch create my-server, the created directory will bemy-server-mcp-server. This suffix is mandatory for all MCP server projects to ensure consistency and clear identification.
Architecture Explanation
Overview
Perch is designed to facilitate the development of MCP HexLayer Architecture servers. It promotes a clean, modular structure by separating concerns into distinct layers: integrations, interfaces (tools, resources, prompts), schemas, and services. This approach, inspired by the Hexagonal Architecture (Ports and Adapters) and primarily based on CGUDL (Create, Get, Update, Delete, List) principles, ensures maintainability, testability, and scalability. The name "Perch" signifies this elevated and clear perspective that clean architecture provides over system layers.
Detailed Architecture
For a comprehensive explanation of the MCP HexLayer Architecture, please refer to the MCP Python SDK repository.
Example Project Structure
my-mcp-server/
├── main.py
├── core/
│ ├── server.py
│ └── data/
│ └── tool.py
├── config/
├── integrations/
│ └── github/
├── interfaces/
│ ├── tools/
│ │ └── github/
│ ├── resources/
│ │ └── github/
│ └── prompts/
├── schemas/
│ └── github/
├── services/
│ └── github/
└── .venv/
Local Development
Installation
add git clone then cd or etc.
To set up Perch for local development:
uv pip install -e .
Then, you can run the CLI:
perch --help
Uninstall
uv pip uninstall perch-py
Reinstall After Edits
uv pip install -e .
License
This project is licensed under the MIT License. See LICENSE for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file perch_py-0.1.3.tar.gz.
File metadata
- Download URL: perch_py-0.1.3.tar.gz
- Upload date:
- Size: 34.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
23df02f1f1f04ed1fb0f7b9fbb54c9516c9fbd4eefbb2140b4b0801d8bed1099
|
|
| MD5 |
06e28fdeb441f49e691671022219eb7f
|
|
| BLAKE2b-256 |
b98b99bbd11a0b062b53affa6afb36a242b8aa3f2923bb615125177d00918db8
|
Provenance
The following attestation bundles were made for perch_py-0.1.3.tar.gz:
Publisher:
publish.yml on danielremoquillo/perch-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
perch_py-0.1.3.tar.gz -
Subject digest:
23df02f1f1f04ed1fb0f7b9fbb54c9516c9fbd4eefbb2140b4b0801d8bed1099 - Sigstore transparency entry: 234371731
- Sigstore integration time:
-
Permalink:
danielremoquillo/perch-py@d9708f6949a5a58f1ccfdb4efa98a8392dd02ef4 -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/danielremoquillo
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@d9708f6949a5a58f1ccfdb4efa98a8392dd02ef4 -
Trigger Event:
push
-
Statement type:
File details
Details for the file perch_py-0.1.3-py3-none-any.whl.
File metadata
- Download URL: perch_py-0.1.3-py3-none-any.whl
- Upload date:
- Size: 13.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f95f6d374b4fdf7d550927290d0dff13049e59bb59fadbdcd8d839ae37a5e992
|
|
| MD5 |
7e300a77acb631ed09a44f8efc02652a
|
|
| BLAKE2b-256 |
1a03ffab8d864ac397cb4b4af6d10564ca64357c35283b54f0054a2591127cdb
|
Provenance
The following attestation bundles were made for perch_py-0.1.3-py3-none-any.whl:
Publisher:
publish.yml on danielremoquillo/perch-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
perch_py-0.1.3-py3-none-any.whl -
Subject digest:
f95f6d374b4fdf7d550927290d0dff13049e59bb59fadbdcd8d839ae37a5e992 - Sigstore transparency entry: 234371734
- Sigstore integration time:
-
Permalink:
danielremoquillo/perch-py@d9708f6949a5a58f1ccfdb4efa98a8392dd02ef4 -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/danielremoquillo
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@d9708f6949a5a58f1ccfdb4efa98a8392dd02ef4 -
Trigger Event:
push
-
Statement type: