THE CUCKOO'S EGG Tracking a Spy Through the Maze of Computer Espionage. By Clifford Stoll. 326 pp. New York: Doubleday. $19.95.

Clifford Stoll's first book, ''The Cuckoo's Egg,'' is both a gripping spy thriller and an intriguing introduction to the futuristic world of international computer networking. It presents a rare view from inside the global village that has been created by the new technologies of data communication. Most improbable of all, this is a true story, subverting our expectations in ways too surprising to be fictitious.

The book's narrator and reluctant hero is a perennial student living in a commune in Berkeley, Calif., at the time these events take place. He eats cashew-butter sandwiches for lunch, sews quilts for relaxation and commutes to work on a bicycle even in the rain: an unlikely character to mount a spy hunt that eventually involves him deeply with the Federal Bureau of Investigation, the Central Intelligence Agency and the National Security Agency.

Mr. Stoll, a temporarily displaced astronomer (his grant money ran out) and a novice manager of the computer system at the Lawrence Berkeley Lab, began his quest when he discovered that a 75-cent accounting error represented a slip by a dangerous invader in the lab's computer system. As a manager of the lab's computer network Mr. Stoll had privileged access to its operating system and therefore was able to observe the intruder lay - electronically - a ''cuckoo's egg,'' a program that a computer unknowingly hatches and feeds until it takes control of an entire system.

Inexorably, Mr. Stoll was drawn into a struggle to protect the international computer networks that connect machines in universities, corporate and government research laboratories and military installations against attacks by computer spies and vandals. In the end, he succeeded not through any act of daring, but because of tenacity, ingenuity and, above all, outrage that a malicious person would threaten his computers and the entire network.

With a plot as exciting as any action novel, ''The Cuckoo's Egg'' is far from a conventional story. The computer spy attacked military and United States Government targets, but the angry response came from the essentially apolitical community of computer and communication wizards. Concocting unique methods to track the spy, Mr. Stoll was able to use his computer to monitor and capture the actual keystrokes that the spy entered on his terminal and to time his intrusions to determine how far away he was. The author also programmed a computer to watch for when the spy broke into the network and then dial Mr. Stoll's pager. He was even able to put static on the spy's telephone connection by jangling a key chain. Lacking search warrants, Mr. Stoll could carry on his quest only by tricking bureaucrats into revealing essential information, persuading technicians to bend rules and doggedly piecing together every scrap of information.

The F.B.I., the C.I.A. and the N.S.A. presented a striking contrast to the author's passionate involvement. Even though the computer spy was clearly seeking information directly related to national security, the agencies failed to provide assistance or useful information during most of the hunt. Instead they used Mr. Stoll's discoveries to gain leverage in interagency wrangling and internal squabbling. The agencies were paralyzed by their own reliance on authority and secrecy, while Mr. Stoll, building on voluntary cooperation and the open exchange of information, was effective in identifying the intruder.

But the central figures in ''The Cuckoo's Egg'' are the computer networks (like Internet, Tymnet and the Defense Data Network) themselves, data highways that carry millions of messages each day among computers all over the world - ''like a post office running at the speed of light.'' Mr. Stoll and his fellow wizards see each network as ''a brain with neurons extending around the world.'' These networks are programmed to adapt to changes in traffic volume and to failures in any of the thousands of on-line computers. On their own, the networks are able to create new communications paths and respond to requests for special services. As computers become smaller, faster and cheaper, networks are becoming pervasive - and merging, eventually to form a single global supernetwork. Networks can carry pictures, documents, software and a variety of other information. They can deliver messages almost instantaneously, so they lend themselves to conversations among almost any number of participants, conversations that can go on for weeks or even months. And networks can also be the theater of a worldwide information war.

Mr. Stoll conducted his search for the computer spy from California, but he watched, and sometimes foiled, attacks on computers located from Japan to Western Europe. The author pursued the spy through supposedly secure computers in Virginia and Massachusetts and helped others track him through the telephone system, satellite links, European computer networks and university computers in West Germany (where, by the way, the spy was finally rooted out). As Mr. Stoll discovered, no one is in charge of the networks. One of the largest, Usenet, is maintained by volunteers, using donated computer time and telephone connections. The networks' safety and future are in the hands of the network community itself.

Computer networks are now at a point in their development comparable to the early versions of printing, the telephone and television. They will have as profound an influence on our culture as any of those other technologies. In the end, the most memorable aspect of ''The Cuckoo's Egg'' is the view it offers of a community and a technology that will play a major role in our future.